File tree Expand file tree Collapse file tree 1 file changed +10
-8
lines changed
plugins/yggdrasil-connect/src/Controllers Expand file tree Collapse file tree 1 file changed +10
-8
lines changed Original file line number Diff line number Diff line change @@ -46,17 +46,19 @@ public function authenticate(Request $request): JsonResponse
4646 $ resp ['user ' ] = ['id ' => User::getUserUuid ($ user ), 'properties ' => []];
4747 }
4848
49- if (!filter_var ($ identification , FILTER_VALIDATE_EMAIL )) {
50- // 如果是角色名登录,就直接绑定角色
51- $ resp ['selectedProfile ' ] = [
52- 'id ' => Profile::getUuidFromName ($ identification ),
53- 'name ' => $ identification ,
54- ];
55- $ resp ['availableProfiles ' ] = [$ resp ['selectedProfile ' ]];
56- } elseif (count ($ availableProfiles ) === 1 ) {
49+ if (count ($ availableProfiles ) === 1 ) {
5750 // 当用户只有一个角色时自动帮他选择
5851 $ resp ['selectedProfile ' ] = $ availableProfiles [0 ];
5952 $ resp ['availableProfiles ' ] = [$ availableProfiles [0 ]];
53+ } elseif (!filter_var ($ identification , FILTER_VALIDATE_EMAIL )) {
54+ // 如果是角色名登录,就直接绑定角色
55+ foreach ($ availableProfiles as $ profile ) {
56+ if (strcasecmp ($ profile ['name ' ], $ identification ) === 0 ) {
57+ $ resp ['selectedProfile ' ] = $ profile ;
58+ $ resp ['availableProfiles ' ] = [$ profile ];
59+ break ;
60+ }
61+ }
6062 } else {
6163 $ resp ['availableProfiles ' ] = $ availableProfiles ;
6264 }
You can’t perform that action at this time.
0 commit comments