header_sso: adaptions for changed internals

This commit is contained in:
verybadsoldier 2023-04-24 20:57:51 +02:00
parent 84533c81d2
commit b32bd95896
3 changed files with 13 additions and 20 deletions

View file

@ -204,18 +204,6 @@ func (svc *UserService) LoginWithoutPassword(ctx context.Context, username strin
return svc.createSessionToken(ctx, usr.ID, extendedSession) return svc.createSessionToken(ctx, usr.ID, extendedSession)
} }
func (svc *UserService) LoginWithoutPassword(ctx context.Context, username string) (UserAuthTokenDetail, error) {
usr, err := svc.repos.Users.GetOneEmail(ctx, username)
if err != nil {
// SECURITY: Perform hash to ensure response times are the same
hasher.CheckPasswordHash("not-a-real-password", "not-a-real-password")
return UserAuthTokenDetail{}, ErrorInvalidLogin
}
return svc.createSessionToken(ctx, usr.ID)
}
func (svc *UserService) Logout(ctx context.Context, token string) error { func (svc *UserService) Logout(ctx context.Context, token string) error {
hash := hasher.HashToken(token) hash := hasher.HashToken(token)
err := svc.repos.AuthTokens.DeleteToken(ctx, hash) err := svc.repos.AuthTokens.DeleteToken(ctx, hash)

View file

@ -122,6 +122,18 @@ class AuthContext implements IAuthContext {
return r; return r;
} }
async login_sso_header(api: PublicApi) {
const r = await api.login_sso_header();
if (!r.error) {
this._token.value = r.data.token;
this._expiresAt.value = r.data.expiresAt as string;
this._attachmentToken.value = r.data.attachmentToken;
}
return r;
}
async logout(api: UserClient) { async logout(api: UserClient) {
const r = await api.user.logout(); const r = await api.user.logout();

View file

@ -32,16 +32,9 @@
} }
}); });
const { data, error } = await api.login_sso_header(); const { error } = await ctx.login_sso_header(api);
if (!error) { if (!error) {
// @ts-expect-error - expires is either a date or a string, need to figure out store typing
authStore.$patch({
token: data.token,
expires: data.expiresAt,
attachmentToken: data.attachmentToken,
});
navigateTo("/home"); navigateTo("/home");
} }