Skip to content

Commit dad3c88

Browse files
authored
Merge pull request #1380 from ORCID/loginIssues
Login issues
2 parents a50bc84 + 5241bc3 commit dad3c88

File tree

6 files changed

+12
-5
lines changed

6 files changed

+12
-5
lines changed

docker-compose.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ services:
3737
- APPLICATION_INTERNAL_ASSERTION_SERVICE_ID=assertion-service-internal
3838
- APPLICATION_INTERNAL_ASSERTION_SERVICE_CLIENT_SECRET=${ASSERTION_SERVICE_INTERNAL_CLIENT_SECRET}
3939
- APPLICATION_SECURITY_ISSUER_URL=${ISSUER_URL}
40-
- UI_REDIRECT_URI=${UI_BASE_URL}/auth/callback
40+
- UI_REDIRECT_URI=${UI_BASE_URL}/en/auth/callback
4141
- UI_POST_LOGOUT_REDIRECT_URI=${UI_BASE_URL}/en/login
4242
volumes:
4343
- ${LOG_VOLUME:-/var/tmp/}:/logs

ui-2/src/app/account/auth.guard.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ import { map, switchMap, take, filter } from 'rxjs/operators' // <--- Import fil
66

77
import { StateStorageService } from './service/state-storage.service'
88
import { AccountService } from './service/account.service'
9+
import { log } from 'console'
910

1011
export const AuthGuard = (route: ActivatedRouteSnapshot, state: RouterStateSnapshot): Observable<boolean> | boolean => {
1112
const authorities = route.data['authorities']
@@ -23,6 +24,7 @@ export const AuthGuard = (route: ActivatedRouteSnapshot, state: RouterStateSnaps
2324
if (state.url === '/login') {
2425
return of(true)
2526
}
27+
console.log('storing state url for redirect after login:', state.url)
2628
stateStorageService.storeUrl(state.url)
2729
router.navigate(['/login'])
2830
return of(false)

ui-2/src/app/account/login/login.component.ts

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -106,10 +106,9 @@ export class LoginComponent implements AfterViewInit, OnDestroy {
106106

107107
this.eventService.broadcast(new Event(EventType.LOG_IN_SUCCESS))
108108

109-
// previousState was set in the authExpiredInterceptor before being redirected to login modal.
110-
// since login is successful, go to stored previousState and clear previousState
111109
const redirect = this.stateStorageService.getUrl()
112110
if (redirect) {
111+
console.log('Redirecting to stored url after login:', redirect)
113112
this.stateStorageService.storeUrl(null)
114113
this.router.navigateByUrl(redirect)
115114
}

ui-2/src/app/app-routing.module.ts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,10 @@ import { AppComponent } from './app.component'
66
import { LoginComponent } from './account'
77

88
const routes: Routes = [
9+
{
10+
path: 'auth/callback',
11+
children: [],
12+
},
913
{
1014
path: '',
1115
loadChildren: () => import('./account/account.module').then((m) => m.AccountModule),

ui-2/src/app/app.component.ts

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,8 +32,10 @@ export class AppComponent implements OnInit {
3232
const redirect = this.stateStorageService.getUrl()
3333
if (redirect) {
3434
this.stateStorageService.storeUrl(null)
35+
console.log('Redirecting to stored url after login:', redirect)
3536
this.router.navigateByUrl(redirect)
36-
} else if (this.router.url.includes('login/callback')) {
37+
} else if (this.router.url.includes('auth/callback')) {
38+
console.log('Oauth callback, navigating to home page after login')
3739
this.router.navigate(['/'])
3840
}
3941
})
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
export const environment = {
22
production: true,
33
issuerUrl: (window as any).__env?.issuerUrl || 'http://localhost:9000',
4-
redirectUri: window.location.origin + '/auth/callback',
4+
redirectUri: window.location.origin + '/en/auth/callback',
55
postLogoutRedirectUri: window.location.origin + '/en/login',
66
}

0 commit comments

Comments
 (0)