Fixed mail login bug🐞📧

ref #107
This commit is contained in:
Nicolai Ort 2021-03-25 17:27:38 +01:00
parent e838e6f321
commit 076893981f

View File

@ -5,6 +5,7 @@
store.init();
import { OpenAPI, AuthService } from "@odit/lfk-client-js";
import Footer from "../general/Footer.svelte";
import isEmail from "validator/es/lib/isEmail";
import Toastify from "toastify-js";
// ------
let username = config.default_username || "";
@ -36,10 +37,19 @@
text: $_("login_is_checked"),
duration: 500,
}).showToast();
AuthService.authControllerLogin({
username,
password,
})
let postdata = {};
if (isEmail(username)) {
postdata = {
email: username,
password,
};
} else {
postdata = {
username,
password,
};
}
AuthService.authControllerLogin(postdata)
.then(async (result) => {
await localForage.setItem("logindata", result);
OpenAPI.TOKEN = result.access_token;