mirror of
https://github.com/hay-kot/homebox.git
synced 2025-08-03 08:10:28 +00:00
header_sso: adaptions for changed internals
This commit is contained in:
parent
84533c81d2
commit
b32bd95896
3 changed files with 13 additions and 20 deletions
|
@ -204,18 +204,6 @@ func (svc *UserService) LoginWithoutPassword(ctx context.Context, username strin
|
|||
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 {
|
||||
hash := hasher.HashToken(token)
|
||||
err := svc.repos.AuthTokens.DeleteToken(ctx, hash)
|
||||
|
|
|
@ -122,6 +122,18 @@ class AuthContext implements IAuthContext {
|
|||
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) {
|
||||
const r = await api.user.logout();
|
||||
|
||||
|
|
|
@ -32,16 +32,9 @@
|
|||
}
|
||||
});
|
||||
|
||||
const { data, error } = await api.login_sso_header();
|
||||
const { error } = await ctx.login_sso_header(api);
|
||||
|
||||
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");
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue