Commit 3cf301a
committed
Fix domain verification error handling using CallbackError
Changes:
- Replace custom DomainVerificationError (inheriting from OmniAuth::Error)
with OmniAuth::Strategies::OAuth2::CallbackError
- This ensures the error is properly caught by omniauth-oauth2's
callback_phase rescue clause instead of bubbling up as a 500 error
- Update test to expect CallbackError with :domain_verification_failed symbol
Rationale:
The omniauth-oauth2 gem's callback_phase only rescues specific error types:
rescue ::OAuth2::Error, CallbackError => e
The previous DomainVerificationError inherited from OmniAuth::Error, which
is not in the rescue clause, causing it to bubble up as an unhandled 500 error.
By using CallbackError (the same pattern used by omniauth-google-oauth2 for
hosted domain verification), the error is automatically caught and converted
to a proper OmniAuth failure with fail!(:invalid_credentials, e).
This provides a better user experience with proper error handling and redirects
instead of 500 error pages.1 parent 9ec7283 commit 3cf301a
File tree
2 files changed
+14
-6
lines changed- lib/omniauth/microsoft_graph
- spec/omniauth/microsoft_graph
2 files changed
+14
-6
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1 | 1 | | |
| 2 | + | |
2 | 3 | | |
3 | | - | |
| 4 | + | |
4 | 5 | | |
5 | 6 | | |
6 | 7 | | |
| |||
11 | 12 | | |
12 | 13 | | |
13 | 14 | | |
14 | | - | |
15 | | - | |
16 | 15 | | |
17 | 16 | | |
18 | 17 | | |
| |||
41 | 40 | | |
42 | 41 | | |
43 | 42 | | |
44 | | - | |
| 43 | + | |
| 44 | + | |
| 45 | + | |
| 46 | + | |
| 47 | + | |
| 48 | + | |
| 49 | + | |
45 | 50 | | |
46 | 51 | | |
47 | 52 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
105 | 105 | | |
106 | 106 | | |
107 | 107 | | |
108 | | - | |
109 | | - | |
| 108 | + | |
| 109 | + | |
| 110 | + | |
| 111 | + | |
| 112 | + | |
110 | 113 | | |
111 | 114 | | |
112 | 115 | | |
| |||
0 commit comments