mirror of
https://github.com/plexguide/Huntarr.io.git
synced 2025-12-23 22:18:23 -05:00
Enhance Plex authentication flow and user redirection
- Updated the user.js file to include a setup_mode flag in the Plex link request, aligning it with the existing setup implementation. - Refined login.html to ensure consistent redirection behavior after successful login and Plex PIN creation. - Modified plex_auth_routes.py to return a redirect URL in the response for successful Plex login and account linking, improving user experience during authentication.
This commit is contained in:
@@ -371,13 +371,15 @@ class UserModule {
|
||||
document.getElementById('plexLinkStatus').textContent = 'Linking account...';
|
||||
|
||||
try {
|
||||
// Use the same approach as setup - let backend get username from database
|
||||
const linkResponse = await fetch('./api/auth/plex/link', {
|
||||
method: 'POST',
|
||||
headers: {
|
||||
'Content-Type': 'application/json'
|
||||
},
|
||||
body: JSON.stringify({
|
||||
token: result.token
|
||||
token: result.token,
|
||||
setup_mode: true // Use setup mode like the working implementation
|
||||
})
|
||||
});
|
||||
|
||||
|
||||
@@ -617,7 +617,7 @@
|
||||
|
||||
if (status === 200 && body.success) {
|
||||
// Login successful
|
||||
window.location.href = body.redirect || './';
|
||||
window.location.href = body.redirect || './';
|
||||
} else if (status === 401 && requires2FA) {
|
||||
// 2FA is required
|
||||
console.log('2FA required, showing 2FA input field');
|
||||
@@ -734,8 +734,8 @@
|
||||
setPlexStatus('waiting', '<i class="fas fa-spinner spinner"></i> Creating Plex PIN...');
|
||||
|
||||
// Create Plex PIN
|
||||
HuntarrUtils.fetchWithTimeout('./api/auth/plex/pin', {
|
||||
method: 'POST',
|
||||
HuntarrUtils.fetchWithTimeout('./api/auth/plex/pin', {
|
||||
method: 'POST',
|
||||
headers: {
|
||||
'Content-Type': 'application/json',
|
||||
},
|
||||
@@ -855,7 +855,7 @@
|
||||
if (data.success) {
|
||||
setPlexStatus('success', '<i class="fas fa-check"></i> Login successful! Redirecting...');
|
||||
setTimeout(() => {
|
||||
window.location.href = './';
|
||||
window.location.href = data.redirect || './';
|
||||
}, 1500);
|
||||
} else {
|
||||
if (status === 409) {
|
||||
|
||||
@@ -195,7 +195,8 @@ def handle_oauth_callback():
|
||||
return jsonify({
|
||||
'success': True,
|
||||
'message': 'Login successful',
|
||||
'user': plex_user_data
|
||||
'user': plex_user_data,
|
||||
'redirect': './'
|
||||
})
|
||||
else:
|
||||
return jsonify({
|
||||
@@ -246,7 +247,8 @@ def plex_login():
|
||||
response = jsonify({
|
||||
'success': True,
|
||||
'message': 'Plex user created and logged in successfully',
|
||||
'auth_type': 'plex'
|
||||
'auth_type': 'plex',
|
||||
'redirect': './'
|
||||
})
|
||||
session[SESSION_COOKIE_NAME] = session_id # Store in Flask session
|
||||
response.set_cookie(SESSION_COOKIE_NAME, session_id,
|
||||
@@ -277,7 +279,8 @@ def plex_login():
|
||||
response = jsonify({
|
||||
'success': True,
|
||||
'message': 'Logged in with Plex successfully',
|
||||
'auth_type': 'plex'
|
||||
'auth_type': 'plex',
|
||||
'redirect': './'
|
||||
})
|
||||
session[SESSION_COOKIE_NAME] = session_id # Store in Flask session
|
||||
response.set_cookie(SESSION_COOKIE_NAME, session_id,
|
||||
|
||||
Reference in New Issue
Block a user