fix: if pubkey isnt registered, error

This commit is contained in:
Derrick Hammer 2024-01-16 16:05:28 -05:00
parent f8d0dc6787
commit d237b42314
Signed by: pcfreak30
GPG Key ID: C997C339BE476FF2
1 changed files with 8 additions and 0 deletions

View File

@ -43,6 +43,7 @@ var (
errEmailAlreadyExists = errors.New("Email already exists")
errGeneratingPassword = errors.New("Error generating password")
errPubkeyAlreadyExists = errors.New("Pubkey already exists")
errPubkeyNotExist = errors.New("Pubkey does not exist")
errAccountLoginErr = errors.New(errAccountLogin)
)
@ -394,6 +395,13 @@ func (h *HttpHandler) AccountLoginChallenge(jc jape.Context) {
return
}
pubkeyExists, _ := h.portal.Accounts().PubkeyExists(hex.EncodeToString(decodedKey[1:]))
if pubkeyExists {
errored(errPubkeyNotExist)
return
}
result := h.portal.Database().Create(&models.S5Challenge{
Challenge: base64.RawURLEncoding.EncodeToString(challenge),
Type: "login",