Skip to content

Commit 84fa814

Browse files
committed
add a text box on login screen that details why the user creation failed if new user creation for oauth service set to false
1 parent 1119b43 commit 84fa814

10 files changed

Lines changed: 118 additions & 18 deletions

dist/3530.0ff1a44f74e08e45.js

Lines changed: 1 addition & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

dist/3530.4352d33e84ff942b.js

Lines changed: 0 additions & 1 deletion
This file was deleted.

dist/index.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,5 +9,5 @@
99
<body class="mat-typography">
1010
<df-root></df-root>
1111
<script type="text/javascript" src="https://assets.calendly.com/assets/external/widget.js"></script>
12-
<script src="runtime.92e02248302e3724.js" type="module"></script><script src="polyfills.def0190516b19e6b.js" type="module"></script><script src="main.1b31dd8117704925.js" type="module"></script></body>
12+
<script src="runtime.aa945f74111dd2d2.js" type="module"></script><script src="polyfills.def0190516b19e6b.js" type="module"></script><script src="main.ad76b60042bfd19e.js" type="module"></script></body>
1313
</html>

dist/main.1b31dd8117704925.js

Lines changed: 0 additions & 1 deletion
This file was deleted.

dist/main.ad76b60042bfd19e.js

Lines changed: 1 addition & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.
Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/app/adf-user-management/df-login/df-login.component.ts

Lines changed: 19 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,7 @@ import { DfThemeService } from 'src/app/shared/services/df-theme.service';
3333
import { CommonModule } from '@angular/common';
3434
import { DfSnackbarService } from 'src/app/shared/services/df-snackbar.service';
3535
import { PopupOverlayService } from 'src/app/shared/components/df-popup/popup-overlay.service';
36+
import { ErrorSharingService } from 'src/app/shared/services/error-sharing.service';
3637

3738
@UntilDestroy({ checkProperties: true })
3839
@Component({
@@ -82,7 +83,8 @@ export class DfLoginComponent implements OnInit {
8283
private router: Router,
8384
private themeService: DfThemeService,
8485
private snackbarService: DfSnackbarService,
85-
private popupOverlay: PopupOverlayService
86+
private popupOverlay: PopupOverlayService,
87+
private errorSharingService: ErrorSharingService
8688
) {
8789
this.loginForm = this.fb.group({
8890
services: [''],
@@ -96,6 +98,22 @@ export class DfLoginComponent implements OnInit {
9698
getIcon = getIcon;
9799

98100
ngOnInit() {
101+
// Check for shared error first
102+
this.errorSharingService.error$.subscribe(sharedError => {
103+
if (sharedError) {
104+
// Decode the error message properly (remove URL encoding)
105+
const decodedError = decodeURIComponent(sharedError.replace(/\+/g, ' '));
106+
107+
// Set the alert message for the built-in alert display
108+
this.alertMsg = decodedError;
109+
this.showAlert = true;
110+
this.alertType = 'error';
111+
112+
// Clear the error after displaying it
113+
this.errorSharingService.clearError();
114+
}
115+
});
116+
99117
this.systemConfigDataService.environment$.subscribe(env => {
100118
this.envloginAttribute = env.authentication.loginAttribute;
101119
this.setLoginAttribute(env.authentication.loginAttribute);

src/app/app.component.ts

Lines changed: 17 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ import { DfLicenseCheckService } from './shared/services/df-license-check.servic
1212
import { UntilDestroy, untilDestroyed } from '@ngneat/until-destroy';
1313
import { AuthService } from './shared/services/auth.service';
1414
import { LoggingService } from './shared/services/logging.service';
15+
import { ErrorSharingService } from './shared/services/error-sharing.service';
1516
import { LoginResponse } from './shared/types/auth.types';
1617
import { ROUTES } from './shared/types/routes';
1718
import { filter } from 'rxjs/operators';
@@ -35,7 +36,8 @@ export class AppComponent implements OnInit {
3536
private authService: AuthService,
3637
private router: Router,
3738
private route: ActivatedRoute,
38-
private loggingService: LoggingService
39+
private loggingService: LoggingService,
40+
private errorSharingService: ErrorSharingService
3941
) {}
4042

4143
ngOnInit() {
@@ -62,7 +64,17 @@ export class AppComponent implements OnInit {
6264
const jwtMatch = fullUrl.match(/[?&]jwt=([^&#]*)/);
6365
const jwt = jwtMatch ? jwtMatch[1] : null;
6466

65-
if (jwt) {
67+
const errorMatch = fullUrl.match(/[?&]error=([^&#]*)/);
68+
const error = errorMatch ? decodeURIComponent(errorMatch[1]) : null;
69+
70+
if (error) {
71+
this.loggingService.log(`OAuth error found: ${error}`);
72+
73+
// Set error in sharing service and navigate to auth/login
74+
this.errorSharingService.setError(error);
75+
this.router.navigate(['/auth/login']);
76+
return;
77+
} else if (jwt) {
6678
this.loggingService.log(`JWT found in URL: ${jwt.substring(0, 20)}...`);
6779
this.authService.loginWithJwt(jwt).subscribe(
6880
(user: LoginResponse) => {
@@ -72,11 +84,11 @@ export class AppComponent implements OnInit {
7284
isAuthenticated ? 'Authenticated' : 'Unknown'
7385
}`
7486
);
75-
window.location.href = '/#/home'; // Use window.location.href for hash-based routing
87+
window.location.href = '/dreamfactory/dist/#/home'; // Use window.location.href for hash-based routing
7688
},
7789
error => {
7890
this.loggingService.log(`Login failed: ${JSON.stringify(error)}`);
79-
window.location.href = '/#/auth/login';
91+
window.location.href = '/dreamfactory/dist/#/auth/login';
8092
}
8193
);
8294
} else {
@@ -87,7 +99,7 @@ export class AppComponent implements OnInit {
8799
);
88100
} else {
89101
this.loggingService.log('User is already logged in');
90-
window.location.href = '/#/home';
102+
window.location.href = '/dreamfactory/dist/#/home';
91103
}
92104
}
93105
}

src/app/login/login.component.ts

Lines changed: 60 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,8 @@ import { Component, OnInit } from '@angular/core';
22
import { AuthService } from '../shared/services/auth.service';
33
import { Router, ActivatedRoute } from '@angular/router';
44
import { UserService } from '../shared/services/user.service';
5-
import { NotificationService } from '../shared/services/notification.service';
5+
import { DfSnackbarService } from '../shared/services/df-snackbar.service';
6+
import { ErrorSharingService } from '../shared/services/error-sharing.service';
67

78
@Component({
89
selector: 'df-app-login',
@@ -15,14 +16,65 @@ export class LoginComponent implements OnInit {
1516
private userService: UserService,
1617
private router: Router,
1718
private route: ActivatedRoute,
18-
private notificationService: NotificationService
19+
private snackbarService: DfSnackbarService,
20+
private errorSharingService: ErrorSharingService
1921
) {}
2022

2123
ngOnInit() {
24+
console.log('LOGIN COMPONENT INIT - Setting up error subscription');
25+
console.log('Error sharing service:', this.errorSharingService);
26+
27+
// Check for shared error first
28+
this.errorSharingService.error$.subscribe(sharedError => {
29+
console.log('LOGIN COMPONENT - Error subscription triggered with:', sharedError);
30+
31+
if (sharedError) {
32+
console.log('Login component received shared error:', sharedError);
33+
34+
// Try multiple approaches to ensure error is visible
35+
const errorMessage = `OAuth Login Error: ${sharedError}`;
36+
37+
// 1. Show browser alert for immediate feedback
38+
console.log('LOGIN COMPONENT - Showing alert');
39+
alert(errorMessage);
40+
41+
// 2. Try snackbar service
42+
try {
43+
console.log('LOGIN COMPONENT - Calling snackbar service');
44+
this.snackbarService.openSnackBar(errorMessage, 'error');
45+
console.log('Snackbar service called successfully');
46+
} catch (snackbarError) {
47+
console.error('Snackbar service failed:', snackbarError);
48+
}
49+
50+
// 3. Also log to console clearly
51+
console.error('OAUTH ERROR FOR USER:', errorMessage);
52+
53+
// Clear the error after displaying it
54+
console.log('LOGIN COMPONENT - Clearing error from service');
55+
this.errorSharingService.clearError();
56+
} else {
57+
console.log('LOGIN COMPONENT - No error received (null/undefined)');
58+
}
59+
});
60+
61+
// Also check query params for backward compatibility
2262
this.route.queryParams.subscribe(params => {
63+
console.log('Login component query params:', params);
2364
const jwt = params['jwt'];
65+
const error = params['error'];
66+
2467
if (jwt) {
68+
console.log('JWT found, handling SAML login');
2569
this.handleSamlLogin(jwt);
70+
} else if (error) {
71+
console.log('Error found in query params:', error);
72+
this.snackbarService.openSnackBar(
73+
`OAuth Login Error: ${decodeURIComponent(error)}`,
74+
'error'
75+
);
76+
} else {
77+
console.log('No JWT or error found in query params');
2678
}
2779
});
2880
}
@@ -33,18 +85,18 @@ export class LoginComponent implements OnInit {
3385
if (result && result.session_token) {
3486
this.router.navigate(['/home']);
3587
} else {
36-
this.notificationService.error(
37-
'Login Error',
38-
'Invalid session token'
88+
this.snackbarService.openSnackBar(
89+
'Login Error: Invalid session token',
90+
'error'
3991
);
4092
this.router.navigate(['/login']);
4193
}
4294
},
4395
error => {
4496
console.error('SAML login failed', error);
45-
this.notificationService.error(
46-
'Login Error',
47-
error.message || 'An error occurred during login.'
97+
this.snackbarService.openSnackBar(
98+
`Login Error: ${error.message || 'An error occurred during login.'}`,
99+
'error'
48100
);
49101
}
50102
);
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
import { Injectable } from '@angular/core';
2+
import { BehaviorSubject } from 'rxjs';
3+
4+
@Injectable({
5+
providedIn: 'root'
6+
})
7+
export class ErrorSharingService {
8+
private errorSubject = new BehaviorSubject<string | null>(null);
9+
public error$ = this.errorSubject.asObservable();
10+
11+
setError(error: string | null) {
12+
this.errorSubject.next(error);
13+
}
14+
15+
clearError() {
16+
this.errorSubject.next(null);
17+
}
18+
}

0 commit comments

Comments
 (0)