Extracted login to shared package
This commit is contained in:
parent
0018ea2bb1
commit
002f28237b
19
src/shared/login.js
Normal file
19
src/shared/login.js
Normal file
@ -0,0 +1,19 @@
|
|||||||
|
import { AuthService, OpenAPI } from "@odit/lfk-client-node";
|
||||||
|
import * as dotenv from 'dotenv';
|
||||||
|
dotenv.config()
|
||||||
|
|
||||||
|
export async function login() {
|
||||||
|
OpenAPI.BASE = process.env.BASE_URL;
|
||||||
|
const user = process.env.USER;
|
||||||
|
const password = process.env.PASSWORD;
|
||||||
|
|
||||||
|
if (!user || !password || !OpenAPI.BASE) {
|
||||||
|
process.exit(1)
|
||||||
|
}
|
||||||
|
|
||||||
|
const auth = await AuthService.authControllerLogin({ username: user, password });
|
||||||
|
OpenAPI.TOKEN = auth.access_token;
|
||||||
|
|
||||||
|
console.log("Logged in");
|
||||||
|
return auth;
|
||||||
|
}
|
Loading…
x
Reference in New Issue
Block a user