fix(caldav): no failed login emails for tokens #1252

Merged
konrad merged 1 commits from LucaBernstein/api:fix-auth-mail-notifications-for-caldav-token-use into main 2022-09-27 15:12:46 +00:00
Contributor

Description

Prevent Vikunja from sending mail notifications for failed login attempts if CalDav token is used.

Before, as the provided password value was tested against the user password regardless of whether it was a CalDav token, it triggered a failed login attempt email every three times.

Checklist

  • I added or improved tests
  • I added or improved docs for my feature
    • Swagger (including mage do-the-swag)
    • Error codes
    • New config options (including adding them to config.yml.saml and running mage generate-docs)
# Description Prevent Vikunja from sending mail notifications for failed login attempts if CalDav token is used. Before, as the provided password value was tested against the user password regardless of whether it was a CalDav token, it triggered a failed login attempt email every three times. # Checklist * [ ] ~~I added or improved tests~~ * [ ] ~~I added or improved docs for my feature~~ * [ ] ~~Swagger (including `mage do-the-swag`)~~ * [ ] ~~Error codes~~ * [ ] ~~New config options (including adding them to `config.yml.saml` and running `mage generate-docs`)~~
konrad reviewed 2022-09-26 15:55:47 +00:00
@ -56,2 +56,2 @@
for _, token := range tokens {
err = bcrypt.CompareHashAndPassword([]byte(token.Token), []byte(password))
func checkUserCaldavTokens(s *xorm.Session, login *user.Login) *user.User {
users, err := user.GetUsersByUsername(s, []string{login.Username}, false)
Owner

Please use GetUserByUsername. There will never be a case where more than one user is returned for one username.

Please use `GetUserByUsername`. There will never be a case where more than one user is returned for one username.
@ -58,0 +57,4 @@
users, err := user.GetUsersByUsername(s, []string{login.Username}, false)
if err != nil || len(users) != 1 {
log.Warningf("Error while retrieving users from database: %v", err)
return nil
Owner

This should return an error.

This should return an error.
konrad requested changes 2022-09-26 15:56:18 +00:00
konrad left a comment
Owner

Already not bad, a few comments.

Already not bad, a few comments.
LucaBernstein force-pushed fix-auth-mail-notifications-for-caldav-token-use from c584da40d7 to 6f0939cbbf 2022-09-27 08:57:57 +00:00 Compare
LucaBernstein force-pushed fix-auth-mail-notifications-for-caldav-token-use from 6f0939cbbf to d468c0cbef 2022-09-27 08:59:31 +00:00 Compare
LucaBernstein force-pushed fix-auth-mail-notifications-for-caldav-token-use from d468c0cbef to 0c31aca607 2022-09-27 09:00:08 +00:00 Compare
konrad approved these changes 2022-09-27 15:06:34 +00:00
konrad scheduled this pull request to auto merge when all checks succeed 2022-09-27 15:06:55 +00:00
konrad merged commit 54b7f7127c into main 2022-09-27 15:12:42 +00:00
Sign in to join this conversation.
No reviewers
No Milestone
No Assignees
2 Participants
Notifications
Due Date
The due date is invalid or out of range. Please use the format 'yyyy-mm-dd'.

No due date set.

Dependencies

No dependencies set.

Reference: vikunja/vikunja#1252
No description provided.