@iodp/geodesc-login v0.0.29
GeodescLogin
This provides a common sign in process for all GEODESC web applications.
Setup
Install the package: npm install @iodp/geodesc-login OR yarn add @iodp/geodesc-login
Import GeodescLoginModule into your app's Core module: import { GeodescLoginModule } from '@iodp/geodesc-login';
... imports: ... GeodescLoginModule ... , ...
- Navigate to the GeodescLoginComponent in your routes: import { GeodescLoginComponent } from '@iodp/geodesc-login';
const routes: Routes = ... { path: 'signin', component: GeodescLoginComponent }, ...
- Add the AuthGuard to any routes that require a user to be signed in: import { AuthGuard } from '@iodp/geodesc-login';
const routes: Routes = [ ... { path: 'project-templates', component: ProjectTemplatesComponent, canActivate: AuthGuard }, ... ]
Handle the navigation for after successful sign in. The user will be directed to the 'welcome' url: const routes: Routes = ... { path: 'welcome', pathMatch: 'full', redirectTo: '/project-templates' }, ...
Include something like the following in your app's startup service: private _destinationSettings: DestinationObject = { press F12 to find the needed properties, including if you must select a project }
private _encryptSettings: EncryptObject = { press F12 to find the needed properties }
constructor(private login: GeodescLoginService) { this.login.setDestination(this._destinationSettings); this.login.setEncryption(this._encryptSettings); }
- Use the public properties and methods from GeodescLoginService: import { User, GeodescLoginService } from '@iodp/geodesc-login';
project: string user: User privileges: string user$: Subject\() errors$: Subject\()
constructor(private login: GeodescLoginService) { this.project = this.login.currentProject this.user = this.login.currentUser this.user$ = this.login.user$ this.errors$ = this.login.loginMessage$
// ONLY NEED TO USE ONE OF THESE this.privileges = this.login.privileges; // this is synchonous but will not have a value until the login call returns this.checkPrivilege() // this will asynchonously give you the privileges as soon as they are available }
checkPrivilege() { this.login.privilege.subscribe(resp => { This contains the user's privileges }) }
logout() { this.login.logout(); this.router.navigate('/signin'); }
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago