@@ -6,18 +6,24 @@ import { Link, useNavigate } from "@tanstack/react-router";
66import { createNotification } from "@app/components/notifications" ;
77import { Button , Input } from "@app/components/v2" ;
88import { useServerConfig } from "@app/context" ;
9+ import { LoginMethod } from "@app/hooks/api/admin/types" ;
910import { loginLDAPRedirect } from "@app/hooks/api/auth/queries" ;
11+ import { useLastLogin } from "@app/hooks/useLastLogin" ;
1012
1113export const LoginLdapPage = ( ) => {
1214 const { t } = useTranslation ( ) ;
1315 const navigate = useNavigate ( ) ;
1416 const { config } = useServerConfig ( ) ;
17+ const { lastLogin, saveLastLogin } = useLastLogin ( ) ;
1518 const queryParams = new URLSearchParams ( window . location . search ) ;
1619 const passedOrgSlug = queryParams . get ( "organizationSlug" ) ;
1720 const passedUsername = queryParams . get ( "username" ) ;
1821
22+ const lastLoginSlug =
23+ lastLogin ?. method === LoginMethod . LDAP && lastLogin . orgSlug ? lastLogin . orgSlug : "" ;
24+
1925 const [ organizationSlug , setOrganizationSlug ] = useState (
20- config . defaultAuthOrgSlug || passedOrgSlug || ""
26+ config . defaultAuthOrgSlug || passedOrgSlug || lastLoginSlug
2127 ) ;
2228 const [ username , setUsername ] = useState ( passedUsername || "" ) ;
2329 const [ password , setPassword ] = useState ( "" ) ;
@@ -40,6 +46,8 @@ export const LoginLdapPage = () => {
4046 return ;
4147 }
4248
49+ saveLastLogin ( { method : LoginMethod . LDAP , orgSlug : organizationSlug } ) ;
50+
4351 createNotification ( {
4452 text : "Successfully logged in" ,
4553 type : "success"
0 commit comments