File tree Expand file tree Collapse file tree 3 files changed +13
-8
lines changed
Expand file tree Collapse file tree 3 files changed +13
-8
lines changed Original file line number Diff line number Diff line change @@ -371,13 +371,15 @@ class UserModule {
371371 document . getElementById ( 'plexLinkStatus' ) . textContent = 'Linking account...' ;
372372
373373 try {
374+ // Use the same approach as setup - let backend get username from database
374375 const linkResponse = await fetch ( './api/auth/plex/link' , {
375376 method : 'POST' ,
376377 headers : {
377378 'Content-Type' : 'application/json'
378379 } ,
379380 body : JSON . stringify ( {
380- token : result . token
381+ token : result . token ,
382+ setup_mode : true // Use setup mode like the working implementation
381383 } )
382384 } ) ;
383385
Original file line number Diff line number Diff line change @@ -617,7 +617,7 @@ <h2>Account Recovery</h2>
617617
618618 if ( status === 200 && body . success ) {
619619 // Login successful
620- window . location . href = body . redirect || './' ;
620+ window . location . href = body . redirect || './' ;
621621 } else if ( status === 401 && requires2FA ) {
622622 // 2FA is required
623623 console . log ( '2FA required, showing 2FA input field' ) ;
@@ -734,8 +734,8 @@ <h2>Account Recovery</h2>
734734 setPlexStatus ( 'waiting' , '<i class="fas fa-spinner spinner"></i> Creating Plex PIN...' ) ;
735735
736736 // Create Plex PIN
737- HuntarrUtils . fetchWithTimeout ( './api/auth/plex/pin' , {
738- method : 'POST' ,
737+ HuntarrUtils . fetchWithTimeout ( './api/auth/plex/pin' , {
738+ method : 'POST' ,
739739 headers : {
740740 'Content-Type' : 'application/json' ,
741741 } ,
@@ -855,7 +855,7 @@ <h2>Account Recovery</h2>
855855 if ( data . success ) {
856856 setPlexStatus ( 'success' , '<i class="fas fa-check"></i> Login successful! Redirecting...' ) ;
857857 setTimeout ( ( ) => {
858- window . location . href = './' ;
858+ window . location . href = data . redirect || './' ;
859859 } , 1500 ) ;
860860 } else {
861861 if ( status === 409 ) {
Original file line number Diff line number Diff line change @@ -195,7 +195,8 @@ def handle_oauth_callback():
195195 return jsonify ({
196196 'success' : True ,
197197 'message' : 'Login successful' ,
198- 'user' : plex_user_data
198+ 'user' : plex_user_data ,
199+ 'redirect' : './'
199200 })
200201 else :
201202 return jsonify ({
@@ -246,7 +247,8 @@ def plex_login():
246247 response = jsonify ({
247248 'success' : True ,
248249 'message' : 'Plex user created and logged in successfully' ,
249- 'auth_type' : 'plex'
250+ 'auth_type' : 'plex' ,
251+ 'redirect' : './'
250252 })
251253 session [SESSION_COOKIE_NAME ] = session_id # Store in Flask session
252254 response .set_cookie (SESSION_COOKIE_NAME , session_id ,
@@ -277,7 +279,8 @@ def plex_login():
277279 response = jsonify ({
278280 'success' : True ,
279281 'message' : 'Logged in with Plex successfully' ,
280- 'auth_type' : 'plex'
282+ 'auth_type' : 'plex' ,
283+ 'redirect' : './'
281284 })
282285 session [SESSION_COOKIE_NAME ] = session_id # Store in Flask session
283286 response .set_cookie (SESSION_COOKIE_NAME , session_id ,
You can’t perform that action at this time.
0 commit comments