clean up
This commit is contained in:
parent
21331e53fe
commit
71dd7f89e9
@ -25,7 +25,7 @@ export class SigninService {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@bindThis
|
@bindThis
|
||||||
public signin(request: FastifyRequest, reply: FastifyReply, user: ILocalUser, redirect = false) {
|
public signin(request: FastifyRequest, reply: FastifyReply, user: ILocalUser) {
|
||||||
setImmediate(async () => {
|
setImmediate(async () => {
|
||||||
// Append signin history
|
// Append signin history
|
||||||
const record = await this.signinsRepository.insert({
|
const record = await this.signinsRepository.insert({
|
||||||
@ -41,25 +41,11 @@ export class SigninService {
|
|||||||
this.globalEventService.publishMainStream(user.id, 'signin', await this.signinEntityService.pack(record));
|
this.globalEventService.publishMainStream(user.id, 'signin', await this.signinEntityService.pack(record));
|
||||||
});
|
});
|
||||||
|
|
||||||
if (redirect) {
|
reply.code(200);
|
||||||
//#region Cookie
|
return {
|
||||||
reply.setCookie('igi', user.token!, {
|
id: user.id,
|
||||||
path: '/',
|
i: user.token,
|
||||||
// SEE: https://github.com/koajs/koa/issues/974
|
};
|
||||||
// When using a SSL proxy it should be configured to add the "X-Forwarded-Proto: https" header
|
|
||||||
secure: this.config.url.startsWith('https'),
|
|
||||||
httpOnly: false,
|
|
||||||
});
|
|
||||||
//#endregion
|
|
||||||
|
|
||||||
reply.redirect(this.config.url);
|
|
||||||
} else {
|
|
||||||
reply.code(200);
|
|
||||||
return {
|
|
||||||
id: user.id,
|
|
||||||
i: user.token,
|
|
||||||
};
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -61,8 +61,6 @@ export async function signout() {
|
|||||||
} catch (err) {}
|
} catch (err) {}
|
||||||
//#endregion
|
//#endregion
|
||||||
|
|
||||||
document.cookie = 'igi=; path=/';
|
|
||||||
|
|
||||||
if (accounts.length > 0) login(accounts[0].token);
|
if (accounts.length > 0) login(accounts[0].token);
|
||||||
else unisonReload('/');
|
else unisonReload('/');
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user