@@ -79,9 +79,18 @@ func handleAzureCallback(w http.ResponseWriter, r *http.Request) {
79
79
handleOauthUserSignUpApprovalPending (w )
80
80
return
81
81
}
82
- // if user exists with provider ID, convert them into email ID
82
+
83
83
user , err := logic .GetUser (content .UserPrincipalName )
84
84
if err == nil {
85
+ // if user exists, then ensure user's auth type is
86
+ // oauth before proceeding.
87
+ if user .AuthType == models .BasicAuth {
88
+ logger .Log (0 , "invalid auth type: basic_auth" )
89
+ handleAuthTypeMismatch (w )
90
+ return
91
+ }
92
+
93
+ // if user exists with provider ID, convert them into email ID
85
94
_ , err := logic .GetUser (content .Email )
86
95
if err != nil {
87
96
user .UserName = content .Email
@@ -91,7 +100,8 @@ func handleAzureCallback(w http.ResponseWriter, r *http.Request) {
91
100
database .Insert (user .UserName , string (d ), database .USERS_TABLE_NAME )
92
101
}
93
102
}
94
- _ , err = logic .GetUser (content .Email )
103
+
104
+ user , err = logic .GetUser (content .Email )
95
105
if err != nil {
96
106
if database .IsEmptyRecord (err ) { // user must not exist, so try to make one
97
107
if inviteExists {
@@ -127,7 +137,16 @@ func handleAzureCallback(w http.ResponseWriter, r *http.Request) {
127
137
handleSomethingWentWrong (w )
128
138
return
129
139
}
140
+ } else {
141
+ // if user exists, then ensure user's auth type is
142
+ // oauth before proceeding.
143
+ if user .AuthType == models .BasicAuth {
144
+ logger .Log (0 , "invalid auth type: basic_auth" )
145
+ handleAuthTypeMismatch (w )
146
+ return
147
+ }
130
148
}
149
+
131
150
user , err = logic .GetUser (content .Email )
132
151
if err != nil {
133
152
handleOauthUserNotFound (w )
0 commit comments