[PR #688] [MERGED] feat(oauth2): add default role assignment for new OAuth2 users #702

Closed
opened 2026-02-26 21:32:32 +03:00 by kerem · 0 comments
Owner

📋 Pull Request Information

Original PR: https://github.com/dreamhunter2333/cloudflare_temp_email/pull/688
Author: @dreamhunter2333
Created: 7/14/2025
Status: Merged
Merged: 7/14/2025
Merged by: @dreamhunter2333

Base: mainHead: feature/dev


📝 Commits (1)

  • 718472d feat(oauth2): add default role assignment for new OAuth2 users

📊 Changes

2 files changed (+17 additions, -1 deletions)

View changed files

📝 CHANGELOG.md (+1 -0)
📝 worker/src/user_api/oauth2.ts (+16 -1)

📄 Description

User description

  • Add default role assignment logic in OAuth2 login flow
  • Import getStringValue and getUserRoles utilities
  • Validate default role exists in system before assignment
  • Use ON CONFLICT DO NOTHING to preserve existing user roles
  • Add proper error handling for role assignment failures

#687


PR Type

Bug fix, Enhancement


Description

  • Assign default roles to new OAuth2 users during registration.

  • Validate the existence of the default role before assignment.

  • Prevent duplicate role assignments using ON CONFLICT DO NOTHING.

  • Improve error handling for role assignment failures.


Changes walkthrough 📝

Relevant files
Enhancement
oauth2.ts
Implement default role assignment in OAuth2 flow                 

worker/src/user_api/oauth2.ts

  • Added logic to assign default roles during OAuth2 user registration.
  • Validated the existence of the default role in the system.
  • Used ON CONFLICT DO NOTHING to avoid duplicate role entries.
  • Enhanced error handling for role assignment and database operations.
  • +16/-1   

    Need help?
  • Type /help how to ... in the comments thread for any questions about PR-Agent usage.
  • Check out the documentation for more information.

  • 🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.

    ## 📋 Pull Request Information **Original PR:** https://github.com/dreamhunter2333/cloudflare_temp_email/pull/688 **Author:** [@dreamhunter2333](https://github.com/dreamhunter2333) **Created:** 7/14/2025 **Status:** ✅ Merged **Merged:** 7/14/2025 **Merged by:** [@dreamhunter2333](https://github.com/dreamhunter2333) **Base:** `main` ← **Head:** `feature/dev` --- ### 📝 Commits (1) - [`718472d`](https://github.com/dreamhunter2333/cloudflare_temp_email/commit/718472d5225e9bd0489589cf4b95407fde2bd2e1) feat(oauth2): add default role assignment for new OAuth2 users ### 📊 Changes **2 files changed** (+17 additions, -1 deletions) <details> <summary>View changed files</summary> 📝 `CHANGELOG.md` (+1 -0) 📝 `worker/src/user_api/oauth2.ts` (+16 -1) </details> ### 📄 Description ### **User description** - Add default role assignment logic in OAuth2 login flow - Import getStringValue and getUserRoles utilities - Validate default role exists in system before assignment - Use ON CONFLICT DO NOTHING to preserve existing user roles - Add proper error handling for role assignment failures #687 ___ ### **PR Type** Bug fix, Enhancement ___ ### **Description** - Assign default roles to new OAuth2 users during registration. - Validate the existence of the default role before assignment. - Prevent duplicate role assignments using `ON CONFLICT DO NOTHING`. - Improve error handling for role assignment failures. ___ ### **Changes walkthrough** 📝 <table><thead><tr><th></th><th align="left">Relevant files</th></tr></thead><tbody><tr><td><strong>Enhancement</strong></td><td><table> <tr> <td> <details> <summary><strong>oauth2.ts</strong><dd><code>Implement default role assignment in OAuth2 flow</code>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </dd></summary> <hr> worker/src/user_api/oauth2.ts <li>Added logic to assign default roles during OAuth2 user registration.<br> <li> Validated the existence of the default role in the system.<br> <li> Used <code>ON CONFLICT DO NOTHING</code> to avoid duplicate role entries.<br> <li> Enhanced error handling for role assignment and database operations. </details> </td> <td><a href="https://github.com/dreamhunter2333/cloudflare_temp_email/pull/688/files#diff-fede9bc68112c797eefa07c6e6cc20a6aa107addb3e5636757131589a435e13b">+16/-1</a>&nbsp; &nbsp; </td> </tr> </table></td></tr></tr></tbody></table> ___ > <details> <summary> Need help?</summary><li>Type <code>/help how to ...</code> in the comments thread for any questions about PR-Agent usage.</li><li>Check out the <a href="https://qodo-merge-docs.qodo.ai/usage-guide/">documentation</a> for more information.</li></details> --- <sub>🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.</sub>
    kerem 2026-02-26 21:32:32 +03:00
    Sign in to join this conversation.
    No milestone
    No project
    No assignees
    1 participant
    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
    starred/cloudflare_temp_email#702
    No description provided.