execute a callback if presented

This commit is contained in:
SrGooglo 2023-08-15 18:44:21 +00:00
parent 3b87fa895b
commit 7fcbedc8f4

View File

@ -4,7 +4,7 @@ import SessionModel from "../session"
const emailRegex = new RegExp(/^[a-zA-Z0-9._-]+@[a-zA-Z0-9.-]+\.[a-zA-Z]{2,4}$/)
export default class AuthModel {
static login = async (payload) => {
static login = async (payload, callback) => {
const response = await request({
method: "post",
url: "/auth/login",
@ -16,6 +16,10 @@ export default class AuthModel {
SessionModel.token = response.data.token
if (typeof callback === "function") {
await callback()
}
__comty_shared_state.eventBus.emit("auth:login_success")
return response.data