@@ -105,7 +105,7 @@ const Login = () => {
105105 } )
106106
107107 const [ loading , data ] = useFetch (
108- async ( ) : Promise < Resp < { token : string } > > => {
108+ async ( ) : Promise < Resp < { token : string ; device_key ?: string } > > => {
109109 if ( useLdap ( ) ) {
110110 return r . post ( "/auth/login/ldap" , {
111111 username : username ( ) ,
@@ -137,7 +137,7 @@ const Login = () => {
137137 credentials : AuthenticationPublicKeyCredential ,
138138 username : string ,
139139 signal : AbortSignal | undefined ,
140- ) : Promise < Resp < { token : string } > > =>
140+ ) : Promise < Resp < { token : string ; device_key ?: string } > > =>
141141 r . post (
142142 "/authn/webauthn_finish_login?username=" + username ,
143143 JSON . stringify ( credentials ) ,
@@ -212,6 +212,19 @@ const Login = () => {
212212 handleRespWithoutNotify ( resp , ( data ) => {
213213 notify . success ( t ( "login.success" ) )
214214 changeToken ( data . token )
215+ // 保存 device_key 到 localStorage
216+ if ( data . device_key ) {
217+ localStorage . setItem ( "device_key" , data . device_key )
218+ console . log ( "=== Login Debug (Hash) ===" )
219+ console . log ( "Saved device_key:" , data . device_key )
220+ console . log ( "Full response data:" , data )
221+ console . log ( "========================" )
222+ } else {
223+ console . log ( "=== Login Debug (Hash) ===" )
224+ console . log ( "No device_key in response" )
225+ console . log ( "Full response data:" , data )
226+ console . log ( "========================" )
227+ }
215228 to (
216229 decodeURIComponent ( searchParams . redirect || base_path || "/" ) ,
217230 true ,
@@ -272,6 +285,19 @@ const Login = () => {
272285 ( data ) => {
273286 notify . success ( t ( "login.success" ) )
274287 changeToken ( data . token )
288+ // 保存 device_key 到 localStorage
289+ if ( data . device_key ) {
290+ localStorage . setItem ( "device_key" , data . device_key )
291+ console . log ( "=== Login Debug ===" )
292+ console . log ( "Saved device_key:" , data . device_key )
293+ console . log ( "Full response data:" , data )
294+ console . log ( "==================" )
295+ } else {
296+ console . log ( "=== Login Debug ===" )
297+ console . log ( "No device_key in response" )
298+ console . log ( "Full response data:" , data )
299+ console . log ( "==================" )
300+ }
275301 to (
276302 decodeURIComponent ( searchParams . redirect || base_path || "/" ) ,
277303 true ,
0 commit comments