The codebase that powers boop.cat boop.cat

always verify user for oauth

+9 -16
+4 -6
backend-go/db/atproto.go
··· 62 62 } 63 63 64 64 if updates { 65 - 66 - _, _ = db.Exec(`UPDATE users SET username = ?, avatarUrl = ?, email = ? WHERE id = ?`, 65 + _, _ = db.Exec(`UPDATE users SET username = ?, avatarUrl = ?, email = ?, emailVerified = 1 WHERE id = ?`, 67 66 user.Username, user.AvatarURL, user.Email, user.ID) 67 + } else { 68 + _, _ = db.Exec(`UPDATE users SET emailVerified = 1 WHERE id = ?`, user.ID) 68 69 } 69 70 70 71 UpdateLastLogin(db, user.ID) ··· 119 120 uid := cuid2.Generate() 120 121 now := time.Now().UTC().Format(time.RFC3339) 121 122 122 - emailVerified := 0 123 - if email != "" { 124 - emailVerified = 1 125 - } 123 + emailVerified := 1 126 124 127 125 _, err = db.Exec(`INSERT INTO users (id, email, username, avatarUrl, emailVerified, createdAt, lastLoginAt) VALUES (?, ?, ?, ?, ?, ?, ?)`, 128 126 uid, finalEmail, username, avatar, emailVerified, now, now)
+5 -10
backend-go/handlers/oauth.go
··· 50 50 51 51 _, _ = h.DB.Exec(`UPDATE oauthAccounts SET accessToken = ? WHERE id = ?`, gothUser.AccessToken, existingAcc.ID) 52 52 53 + h.DB.Exec(`UPDATE users SET emailVerified = 1 WHERE id = ?`, existingAcc.UserID) 54 + 53 55 if err := middleware.LoginUser(w, r, existingAcc.UserID); err != nil { 54 56 http.Redirect(w, r, "/?error=session-error", http.StatusTemporaryRedirect) 55 57 return ··· 78 80 return 79 81 } 80 82 83 + h.DB.Exec(`UPDATE users SET emailVerified = 1 WHERE id = ?`, existingUser.ID) 84 + 81 85 if err := middleware.LoginUser(w, r, existingUser.ID); err != nil { 82 86 http.Redirect(w, r, "/?error=session-error", http.StatusTemporaryRedirect) 83 87 return ··· 95 99 return 96 100 } 97 101 98 - verified := false 99 - if v, ok := gothUser.RawData["verified"].(bool); ok && v { 100 - verified = true 101 - } else if v, ok := gothUser.RawData["email_verified"].(bool); ok && v { 102 - verified = true 103 - } 104 - 105 - if verified { 106 - _, _ = h.DB.Exec(`UPDATE users SET emailVerified = 1 WHERE id = ?`, userID) 107 - } 102 + _, _ = h.DB.Exec(`UPDATE users SET emailVerified = 1 WHERE id = ?`, userID) 108 103 109 104 err = db.CreateOAuthAccount(h.DB, cuid2.Generate(), provider, gothUser.UserID, userID, gothUser.AccessToken, gothUser.Name) 110 105 if err != nil {