Skip to content

Commit

Permalink
fix: Invite page in ssr is not working (#1200)
Browse files Browse the repository at this point in the history
* fix: add noop impl for triggerInvite function

* docs: document requirements per case

* fix: add change password guard

* Minor details
  • Loading branch information
jometzner authored Jul 14, 2022
1 parent 4b34589 commit 215525e
Show file tree
Hide file tree
Showing 5 changed files with 35 additions and 0 deletions.
16 changes: 16 additions & 0 deletions docs/concepts/sso.md
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,22 @@ For development purposes the configuration can be added to the Angular CLI envir
For production, this configuration should be provided to the SSR process via environment variables (see [Building and Running Server-Side Rendering][ssr-startup]).
The usage of identity providers can also be set in the multi-channel configuration (see [Building and Running nginx Docker Image][nginx-startup]).

## Business cases

### Create new user

| Authentication Provider | Route in ICM email | Behavior of PWA |
| ----------------------- | ------------------ | ------------------------------------------ |
| ICM | /invite | Redirect to /forgotPassword/updatePassword |
| SSO | /invite | Redirect to SSO provider |

### User forgot password

| Authentication Provider | Route in ICM email | Behavior of PWA |
| ----------------------- | ------------------------------ | ------------------------- |
| ICM | /forgotPassword/updatePassword | Show change password form |
| SSO | /forgotPassword/updatePassword | Redirect to SSO provider |

# Further References

- PWA
Expand Down
15 changes: 15 additions & 0 deletions src/app/core/guards/identity-provider-password.guard.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
import { Injectable } from '@angular/core';
import { ActivatedRouteSnapshot, CanActivate, RouterStateSnapshot } from '@angular/router';

import { IdentityProviderFactory } from 'ish-core/identity-provider/identity-provider.factory';

@Injectable({ providedIn: 'root' })
export class IdentityProviderPasswordGuard implements CanActivate {
constructor(private identityProviderFactory: IdentityProviderFactory) {}

canActivate(route: ActivatedRouteSnapshot, state: RouterStateSnapshot) {
return this.identityProviderFactory.getType() !== 'ICM' && this.identityProviderFactory.getInstance().triggerInvite
? this.identityProviderFactory.getInstance().triggerInvite(route, state)
: true;
}
}
1 change: 1 addition & 0 deletions src/app/core/identity-provider.module.ts
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,7 @@ export class IdentityProviderModule {
intercept: (req: HttpRequest<unknown>, next: HttpHandler) => next.handle(req),
triggerLogin: () => true,
triggerLogout: () => true,
triggerInvite: () => true,
getCapabilities: () => capabilities,
}),
getType: () => 'ICM',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,7 @@ export class IdentityProviderFactory {
intercept: (req, next) => next.handle(req),
triggerLogin: () => true,
triggerLogout: () => true,
triggerInvite: () => true,
getCapabilities: () => ({}),
};
}
Expand Down
2 changes: 2 additions & 0 deletions src/app/pages/forgot-password/forgot-password-page.module.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import { NgModule } from '@angular/core';
import { RouterModule, Routes } from '@angular/router';

import { IdentityProviderPasswordGuard } from 'ish-core/guards/identity-provider-password.guard';
import { SharedModule } from 'ish-shared/shared.module';

import { RequestReminderFormComponent } from './request-reminder-form/request-reminder-form.component';
Expand All @@ -16,6 +17,7 @@ const forgotPasswordPageRoutes: Routes = [
{
path: 'updatePassword',
component: UpdatePasswordComponent,
canActivate: [IdentityProviderPasswordGuard],
},
];

Expand Down

0 comments on commit 215525e

Please sign in to comment.