File tree Expand file tree Collapse file tree 1 file changed +14
-5
lines changed Expand file tree Collapse file tree 1 file changed +14
-5
lines changed Original file line number Diff line number Diff line change @@ -161,14 +161,23 @@ func GetUserByLogin(query *m.GetUserByLoginQuery) error {
161
161
}
162
162
163
163
user := new (m.User )
164
- if strings .Contains (query .LoginOrEmail , "@" ) {
165
- user = & m.User {Email : query .LoginOrEmail }
166
- } else {
167
- user = & m.User {Login : query .LoginOrEmail }
168
- }
169
164
165
+ // Try and find the user by login first.
166
+ // It's not sufficient to assume that a LoginOrEmail with an "@" is an email.
167
+ user = & m.User {Login : query .LoginOrEmail }
170
168
has , err := x .Get (user )
171
169
170
+ if err != nil {
171
+ return err
172
+ }
173
+
174
+ if has == false && strings .Contains (query .LoginOrEmail , "@" ) {
175
+ // If the user wasn't found, and it contains an "@" fallback to finding the
176
+ // user by email.
177
+ user = & m.User {Email : query .LoginOrEmail }
178
+ has , err = x .Get (user )
179
+ }
180
+
172
181
if err != nil {
173
182
return err
174
183
} else if has == false {
You can’t perform that action at this time.
0 commit comments