Refactor most login providers in order to work on window popups and add proper login support for the link new user
This commit is contained in:
parent
df3a5e81a5
commit
c8a163f4aa
|
@ -43,6 +43,7 @@ import { ConfigurationService } from './services/configuration/configuration.ser
|
||||||
import { HttpClient } from '@angular/common/http';
|
import { HttpClient } from '@angular/common/http';
|
||||||
import { LanguageInfoService } from './services/culture/language-info-service';
|
import { LanguageInfoService } from './services/culture/language-info-service';
|
||||||
import { CurrencyService } from './services/currency/currency.service';
|
import { CurrencyService } from './services/currency/currency.service';
|
||||||
|
import { MergeEmailConfirmationService } from './services/merge-email-confirmation/merge-email-confirmation.service';
|
||||||
//
|
//
|
||||||
//
|
//
|
||||||
// This is shared module that provides all the services. Its imported only once on the AppModule.
|
// This is shared module that provides all the services. Its imported only once on the AppModule.
|
||||||
|
@ -107,6 +108,7 @@ export class CoreServiceModule {
|
||||||
LockService,
|
LockService,
|
||||||
UserGuideService,
|
UserGuideService,
|
||||||
CurrencyService,
|
CurrencyService,
|
||||||
|
MergeEmailConfirmationService,
|
||||||
ConfigurationService,
|
ConfigurationService,
|
||||||
{
|
{
|
||||||
provide: APP_INITIALIZER,
|
provide: APP_INITIALIZER,
|
||||||
|
|
|
@ -91,6 +91,13 @@ export class AuthService extends BaseService {
|
||||||
}));
|
}));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public mergeLogin(loginInfo: LoginInfo): Observable<any> {
|
||||||
|
this.actionUrl = this.configurationService.server + 'auth/';
|
||||||
|
const url = this.actionUrl + 'externallogin';
|
||||||
|
|
||||||
|
return this.http.post(url, loginInfo, { headers: this.headers });
|
||||||
|
}
|
||||||
|
|
||||||
public nativeLogin(credentials: Credential): Observable<Principal> {
|
public nativeLogin(credentials: Credential): Observable<Principal> {
|
||||||
this.actionUrl = this.configurationService.server + 'auth/';
|
this.actionUrl = this.configurationService.server + 'auth/';
|
||||||
const url = this.actionUrl + 'nativelogin';
|
const url = this.actionUrl + 'nativelogin';
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
import { HttpClient, HttpHeaders } from '@angular/common/http';
|
import { HttpClient, HttpHeaders } from '@angular/common/http';
|
||||||
import { Component, OnInit } from '@angular/core';
|
import { Component, OnInit } from '@angular/core';
|
||||||
import { ActivatedRoute, Params } from '@angular/router';
|
import { ActivatedRoute, Params, Router } from '@angular/router';
|
||||||
import { AuthProvider } from '@app/core/common/enum/auth-provider';
|
import { AuthProvider } from '@app/core/common/enum/auth-provider';
|
||||||
import { AuthService } from '@app/core/services/auth/auth.service';
|
import { AuthService } from '@app/core/services/auth/auth.service';
|
||||||
import { LoginService } from '@app/ui/auth/login/utilities/login.service';
|
import { LoginService } from '@app/ui/auth/login/utilities/login.service';
|
||||||
|
@ -22,7 +22,8 @@ export class B2AccessLoginComponent extends BaseComponent implements OnInit {
|
||||||
private authService: AuthService,
|
private authService: AuthService,
|
||||||
private loginService: LoginService,
|
private loginService: LoginService,
|
||||||
private httpClient: HttpClient,
|
private httpClient: HttpClient,
|
||||||
private configurationService: ConfigurationService
|
private configurationService: ConfigurationService,
|
||||||
|
private router: Router
|
||||||
) {
|
) {
|
||||||
super();
|
super();
|
||||||
}
|
}
|
||||||
|
@ -31,9 +32,10 @@ export class B2AccessLoginComponent extends BaseComponent implements OnInit {
|
||||||
this.route.queryParams
|
this.route.queryParams
|
||||||
.pipe(takeUntil(this._destroyed))
|
.pipe(takeUntil(this._destroyed))
|
||||||
.subscribe((params: Params) => {
|
.subscribe((params: Params) => {
|
||||||
const returnUrl = params['returnUrl'];
|
// const returnUrl = params['returnUrl'];
|
||||||
if (returnUrl) { this.returnUrl = returnUrl; }
|
// if (returnUrl) { this.returnUrl = returnUrl; }
|
||||||
if (!params['code']) { this.b2AccessGetAuthCode(); } else { this.b2AccessLogin(params['code']); }
|
// if (!params['code']) { this.b2AccessGetAuthCode(); } else { this.b2AccessLogin(params['code']); }
|
||||||
|
this.router.navigate(['/oauth2'], {queryParams: params});
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -32,9 +32,10 @@ export class LinkedInLoginComponent extends BaseComponent implements OnInit {
|
||||||
this.route.queryParams
|
this.route.queryParams
|
||||||
.pipe(takeUntil(this._destroyed))
|
.pipe(takeUntil(this._destroyed))
|
||||||
.subscribe((params: Params) => {
|
.subscribe((params: Params) => {
|
||||||
const returnUrl = params['returnUrl'];
|
// const returnUrl = params['returnUrl'];
|
||||||
if (returnUrl) { this.returnUrl = returnUrl; }
|
// if (returnUrl) { this.returnUrl = returnUrl; }
|
||||||
if (!params['code']) { this.linkedinAuthorize(); } else { this.linkedInLoginUser(params['code'], params['state']); }
|
// if (!params['code']) { this.linkedinAuthorize(); } else { this.linkedInLoginUser(params['code'], params['state']); }
|
||||||
|
this.router.navigate(['/oauth2'], {queryParams: params});
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -9,6 +9,14 @@ import { BaseComponent } from '@common/base/base.component';
|
||||||
import { environment } from 'environments/environment';
|
import { environment } from 'environments/environment';
|
||||||
import { takeUntil } from 'rxjs/operators';
|
import { takeUntil } from 'rxjs/operators';
|
||||||
import { ConfigurationService } from '@app/core/services/configuration/configuration.service';
|
import { ConfigurationService } from '@app/core/services/configuration/configuration.service';
|
||||||
|
import { MergeLoginService } from './utilities/merge-login.service';
|
||||||
|
import { Oauth2DialogService } from '@app/ui/misc/oauth2-dialog/service/oauth2-dialog.service';
|
||||||
|
import { HttpClient, HttpHeaders } from '@angular/common/http';
|
||||||
|
import { BehaviorSubject } from 'rxjs';
|
||||||
|
import { FormControl } from '@angular/forms';
|
||||||
|
import { OrcidUser } from '@app/core/model/orcid/orcidUser';
|
||||||
|
import { ZenodoToken } from '@app/core/model/zenodo/zenodo-token.model';
|
||||||
|
import { LoginInfo } from '@app/core/model/auth/login-info';
|
||||||
|
|
||||||
/// <reference types="gapi" />
|
/// <reference types="gapi" />
|
||||||
/// <reference types="facebook-js-sdk" />
|
/// <reference types="facebook-js-sdk" />
|
||||||
|
@ -27,6 +35,11 @@ export class LoginComponent extends BaseComponent implements OnInit, AfterViewIn
|
||||||
|
|
||||||
public auth2: any;
|
public auth2: any;
|
||||||
private returnUrl: string;
|
private returnUrl: string;
|
||||||
|
private twitterUrl = new BehaviorSubject(undefined);
|
||||||
|
private emailFormControl = new FormControl('');
|
||||||
|
private orcidUser: OrcidUser;
|
||||||
|
private zenodoToken: ZenodoToken;
|
||||||
|
private accessToken: string;
|
||||||
//public cofigurableProviders: ConfigurableProvider[];
|
//public cofigurableProviders: ConfigurableProvider[];
|
||||||
|
|
||||||
constructor(
|
constructor(
|
||||||
|
@ -35,7 +48,10 @@ export class LoginComponent extends BaseComponent implements OnInit, AfterViewIn
|
||||||
private loginService: LoginService,
|
private loginService: LoginService,
|
||||||
private authService: AuthService,
|
private authService: AuthService,
|
||||||
public configurableProviderService: ConfigurableProvidersService,
|
public configurableProviderService: ConfigurableProvidersService,
|
||||||
private configurationService: ConfigurationService
|
private configurationService: ConfigurationService,
|
||||||
|
private mergeLoginService: MergeLoginService,
|
||||||
|
private oauth2DialogService: Oauth2DialogService,
|
||||||
|
private httpClient: HttpClient
|
||||||
) { super(); }
|
) { super(); }
|
||||||
|
|
||||||
ngOnInit(): void {
|
ngOnInit(): void {
|
||||||
|
@ -57,23 +73,58 @@ export class LoginComponent extends BaseComponent implements OnInit, AfterViewIn
|
||||||
}
|
}
|
||||||
|
|
||||||
public linkedInLogin() {
|
public linkedInLogin() {
|
||||||
this.router.navigate(['/login/linkedin']);
|
//this.router.navigate(['/login/linkedin']);
|
||||||
|
this.oauth2DialogService.login(this.getLinkedInUrl()).pipe(takeUntil(this._destroyed))
|
||||||
|
.subscribe(result => {
|
||||||
|
if (result !== undefined) {
|
||||||
|
this.linkedInLoginUser(result.oauthCode, result.oauthState);
|
||||||
|
}
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
public twitterLogin() {
|
public twitterLogin() {
|
||||||
this.router.navigate(['/login/twitter']);
|
// this.router.navigate(['/login/twitter']);
|
||||||
|
this.twitterUrl.asObservable().pipe(takeUntil(this._destroyed)).subscribe(url => {
|
||||||
|
if (url !== undefined) {
|
||||||
|
this.oauth2DialogService.login(url).pipe(takeUntil(this._destroyed))
|
||||||
|
.subscribe(result => {
|
||||||
|
if (result !== undefined) {
|
||||||
|
this.twitterLoginUser(result.oauthToken, result.oauthVerifier);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
});
|
||||||
|
this.twitterAuthorize();
|
||||||
}
|
}
|
||||||
|
|
||||||
public b2AccessLogin() {
|
public b2AccessLogin() {
|
||||||
this.router.navigate(['/login/external/b2access']);
|
//this.router.navigate(['/login/external/b2access'], {queryParams: {returnUrl: this.returnUrl, mergeUsers: this.mergeUsers}});
|
||||||
|
this.oauth2DialogService.login(this.getB2AccessUrl()).pipe(takeUntil(this._destroyed))
|
||||||
|
.subscribe(result => {
|
||||||
|
if (result !== undefined) {
|
||||||
|
this.b2AccessLoginUser(result.oauthCode);
|
||||||
|
}
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
public orcidLogin() {
|
public orcidLogin() {
|
||||||
this.router.navigate(['/login/external/orcid']);
|
//this.router.navigate(['/login/external/orcid']);
|
||||||
|
this.oauth2DialogService.login(this.getORCIDUrl()).pipe(takeUntil(this._destroyed))
|
||||||
|
.subscribe(result => {
|
||||||
|
if (result !== undefined) {
|
||||||
|
this.orcidLoginUser(result.oauthCode);
|
||||||
|
}
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
public openaireLogin() {
|
public openaireLogin() {
|
||||||
this.router.navigate(['/login/openaire']);
|
//this.router.navigate(['/login/openaire']);
|
||||||
|
this.oauth2DialogService.login(this.getOpenAireUrl()).pipe(takeUntil(this._destroyed))
|
||||||
|
.subscribe(result => {
|
||||||
|
if (result !== undefined) {
|
||||||
|
this.openaireLoginUser(result.oauthCode, result.oauthState);
|
||||||
|
}
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
public configurableLogin(provider: ConfigurableProvider) {
|
public configurableLogin(provider: ConfigurableProvider) {
|
||||||
|
@ -81,7 +132,13 @@ export class LoginComponent extends BaseComponent implements OnInit, AfterViewIn
|
||||||
}
|
}
|
||||||
|
|
||||||
public zenodoLogin() {
|
public zenodoLogin() {
|
||||||
this.router.navigate(['/login/external/zenodo']);
|
//this.router.navigate(['/login/external/zenodo']);
|
||||||
|
this.oauth2DialogService.login(this.getZenodoUrl()).pipe(takeUntil(this._destroyed))
|
||||||
|
.subscribe(result => {
|
||||||
|
if (result !== undefined) {
|
||||||
|
this.zenodoLoginUser(result.oauthCode);
|
||||||
|
}
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
public hasFacebookOauth(): boolean {
|
public hasFacebookOauth(): boolean {
|
||||||
|
@ -166,12 +223,7 @@ export class LoginComponent extends BaseComponent implements OnInit, AfterViewIn
|
||||||
(googleUser) => {
|
(googleUser) => {
|
||||||
const id_token = googleUser.getAuthResponse().id_token;
|
const id_token = googleUser.getAuthResponse().id_token;
|
||||||
if (id_token) {
|
if (id_token) {
|
||||||
this.authService.login({ ticket: id_token, provider: AuthProvider.Google })
|
this.authLogin({ ticket: id_token, provider: AuthProvider.Google });
|
||||||
.pipe(takeUntil(this._destroyed))
|
|
||||||
.subscribe(
|
|
||||||
res => this.loginService.onLogInSuccess(res, this.returnUrl),
|
|
||||||
error => this.loginService.onLogInError(error)
|
|
||||||
);
|
|
||||||
}
|
}
|
||||||
}, (error) => {
|
}, (error) => {
|
||||||
});
|
});
|
||||||
|
@ -192,12 +244,7 @@ export class LoginComponent extends BaseComponent implements OnInit, AfterViewIn
|
||||||
public facebookLogin() {
|
public facebookLogin() {
|
||||||
FB.login((response: any) => {
|
FB.login((response: any) => {
|
||||||
if (response.status === 'connected' || 'not_authorized') {
|
if (response.status === 'connected' || 'not_authorized') {
|
||||||
this.authService.login({ ticket: response.authResponse.accessToken, provider: AuthProvider.Facebook })
|
this.authLogin({ ticket: response.authResponse.accessToken, provider: AuthProvider.Facebook });
|
||||||
.pipe(takeUntil(this._destroyed))
|
|
||||||
.subscribe(
|
|
||||||
res => this.loginService.onLogInSuccess(res, this.returnUrl),
|
|
||||||
error => this.loginService.onLogInError(error)
|
|
||||||
);
|
|
||||||
}
|
}
|
||||||
}, { scope: 'email' });
|
}, { scope: 'email' });
|
||||||
}
|
}
|
||||||
|
@ -205,4 +252,144 @@ export class LoginComponent extends BaseComponent implements OnInit, AfterViewIn
|
||||||
public hasConfigurableProviders(): boolean {
|
public hasConfigurableProviders(): boolean {
|
||||||
return !(this.configurableProviderService.providers == undefined) && this.configurableProviderService.providers.length > 0
|
return !(this.configurableProviderService.providers == undefined) && this.configurableProviderService.providers.length > 0
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private getLinkedInUrl() {
|
||||||
|
return this.configurationService.loginProviders.linkedInConfiguration.oauthUrl
|
||||||
|
+ '?response_type=code&client_id=' + this.configurationService.loginProviders.linkedInConfiguration.clientId
|
||||||
|
+ '&redirect_uri=' + this.configurationService.loginProviders.linkedInConfiguration.redirectUri
|
||||||
|
+ '&state=' + this.configurationService.loginProviders.linkedInConfiguration.state
|
||||||
|
+ '&scope=r_emailaddress';
|
||||||
|
}
|
||||||
|
|
||||||
|
public linkedInLoginUser(code: string, state: string) {
|
||||||
|
if (state !== this.configurationService.loginProviders.linkedInConfiguration.state) {
|
||||||
|
this.router.navigate(['/login']);
|
||||||
|
}
|
||||||
|
this.httpClient.post(this.configurationService.server + 'auth/linkedInRequestToken', { code: code, provider: AuthProvider.LinkedIn })
|
||||||
|
.pipe(takeUntil(this._destroyed))
|
||||||
|
.subscribe((data: any) => {
|
||||||
|
this.authLogin({ ticket: data.payload.accessToken, provider: AuthProvider.LinkedIn, data: null });
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
public twitterAuthorize() {
|
||||||
|
let headers = new HttpHeaders();
|
||||||
|
headers = headers.set('Content-Type', 'application/json');
|
||||||
|
headers = headers.set('Accept', 'application/json');
|
||||||
|
this.httpClient.get(this.configurationService.server + 'auth/twitterRequestToken', { headers: headers })
|
||||||
|
.pipe(takeUntil(this._destroyed))
|
||||||
|
.subscribe((data: any) => {
|
||||||
|
this.twitterUrl.next(this.configurationService.loginProviders.twitterConfiguration.oauthUrl + '?oauth_token=' + data.value);
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
public twitterLoginUser(token: string, verifier: string) {
|
||||||
|
const data = {
|
||||||
|
email: this.emailFormControl.value, verifier: verifier
|
||||||
|
};
|
||||||
|
this.authLogin({ ticket: token, provider: AuthProvider.Twitter, data: data });
|
||||||
|
}
|
||||||
|
|
||||||
|
private getB2AccessUrl() {
|
||||||
|
return this.configurationService.loginProviders.b2accessConfiguration.oauthUrl
|
||||||
|
+ '?response_type=code&client_id=' + this.configurationService.loginProviders.b2accessConfiguration.clientId
|
||||||
|
+ '&redirect_uri=' + this.configurationService.loginProviders.b2accessConfiguration.redirectUri
|
||||||
|
+ '&state=' + this.configurationService.loginProviders.b2accessConfiguration.state
|
||||||
|
+ '&scope=USER_PROFILE';
|
||||||
|
}
|
||||||
|
|
||||||
|
public b2AccessLoginUser(code: String) {
|
||||||
|
let headers = new HttpHeaders();
|
||||||
|
headers = headers.set('Content-Type', 'application/json');
|
||||||
|
headers = headers.set('Accept', 'application/json');
|
||||||
|
this.httpClient.post(this.configurationService.server + 'auth/b2AccessRequestToken', { code: code }, { headers: headers })
|
||||||
|
.pipe(takeUntil(this._destroyed))
|
||||||
|
.subscribe((data: any) => {
|
||||||
|
this.authLogin({ ticket: data.payload.accessToken, provider: AuthProvider.B2Access, data: null });
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
private getORCIDUrl() {
|
||||||
|
return this.configurationService.loginProviders.orcidConfiguration.oauthUrl
|
||||||
|
+ '?client_id='
|
||||||
|
+ this.configurationService.loginProviders.orcidConfiguration.clientId
|
||||||
|
+ '&response_type=code&scope=/authenticate&redirect_uri='
|
||||||
|
+ this.configurationService.loginProviders.orcidConfiguration.redirectUri;
|
||||||
|
}
|
||||||
|
|
||||||
|
public orcidLoginUser(code: string) {
|
||||||
|
let headers = new HttpHeaders();
|
||||||
|
headers = headers.set('Content-Type', 'application/json');
|
||||||
|
headers = headers.set('Accept', 'application/json');
|
||||||
|
this.httpClient.post(this.configurationService.server + 'auth/orcidRequestToken', { code: code }, { headers: headers })
|
||||||
|
.pipe(takeUntil(this._destroyed))
|
||||||
|
.subscribe((responseData: any) => {
|
||||||
|
this.orcidUser = new OrcidUser();
|
||||||
|
this.orcidUser.orcidId = responseData.payload.orcidId
|
||||||
|
this.orcidUser.name = responseData.payload.name
|
||||||
|
this.accessToken = responseData.payload.accessToken;
|
||||||
|
this.authLogin({ ticket: this.accessToken, provider: AuthProvider.ORCID, data: this.orcidUser });
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
private getOpenAireUrl() {
|
||||||
|
return this.configurationService.loginProviders.openAireConfiguration.oauthUrl
|
||||||
|
+ '?response_type=code&client_id=' + this.configurationService.loginProviders.openAireConfiguration.clientId
|
||||||
|
+ '&redirect_uri=' + this.configurationService.loginProviders.openAireConfiguration.redirectUri
|
||||||
|
+ '&state=' + this.configurationService.loginProviders.openAireConfiguration.state
|
||||||
|
+ '&scope=openid profile email';
|
||||||
|
}
|
||||||
|
|
||||||
|
public openaireLoginUser(code: string, state: string) {
|
||||||
|
if (state !== this.configurationService.loginProviders.openAireConfiguration.state) {
|
||||||
|
this.router.navigate(['/login'])
|
||||||
|
}
|
||||||
|
this.httpClient.post(this.configurationService.server + 'auth/openAireRequestToken', { code: code, provider: AuthProvider.OpenAire })
|
||||||
|
.pipe(takeUntil(this._destroyed))
|
||||||
|
.subscribe((data: any) => {
|
||||||
|
this.authLogin({ ticket: data.payload.accessToken, provider: AuthProvider.OpenAire, data: null });
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
private getZenodoUrl() {
|
||||||
|
return this.configurationService.loginProviders.zenodoConfiguration.oauthUrl
|
||||||
|
+ '?client_id='
|
||||||
|
+ this.configurationService.loginProviders.zenodoConfiguration.clientId
|
||||||
|
+ '&response_type=code&scope=deposit:write+deposit:actions+user:email&state=astate&redirect_uri='
|
||||||
|
+ this.configurationService.loginProviders.zenodoConfiguration.redirectUri;
|
||||||
|
}
|
||||||
|
|
||||||
|
public zenodoLoginUser(code: string) {
|
||||||
|
let headers = new HttpHeaders();
|
||||||
|
headers = headers.set('Content-Type', 'application/json');
|
||||||
|
headers = headers.set('Accept', 'application/json');
|
||||||
|
this.httpClient.post(this.configurationService.server + 'auth/zenodoRequestToken', { code: code }, { headers: headers })
|
||||||
|
.pipe(takeUntil(this._destroyed))
|
||||||
|
.subscribe((responseData: any) => {
|
||||||
|
this.zenodoToken = new ZenodoToken();
|
||||||
|
this.zenodoToken.userId = responseData.payload.userId;
|
||||||
|
this.zenodoToken.expiresIn = responseData.payload.expiresIn;
|
||||||
|
this.accessToken = this.zenodoToken.accessToken = responseData.payload.accessToken;
|
||||||
|
this.zenodoToken.email = responseData.payload.email;
|
||||||
|
this.zenodoToken.refreshToken = responseData.payload.refreshToken;
|
||||||
|
this.authLogin({ ticket: this.accessToken, provider: AuthProvider.Zenodo, data: this.zenodoToken });
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
private authLogin(loginInfo: LoginInfo) {
|
||||||
|
if (this.mergeUsers) {
|
||||||
|
this.authService.mergeLogin(loginInfo)
|
||||||
|
.pipe(takeUntil(this._destroyed))
|
||||||
|
.subscribe(
|
||||||
|
res => this.mergeLoginService.setRequest({email: res.payload.email, userId: res.payload.id})
|
||||||
|
);
|
||||||
|
} else {
|
||||||
|
this.authService.login(loginInfo)
|
||||||
|
.pipe(takeUntil(this._destroyed))
|
||||||
|
.subscribe(
|
||||||
|
res => this.loginService.onLogInSuccess(res, this.returnUrl),
|
||||||
|
error => this.loginService.onLogInError(error)
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -12,6 +12,7 @@ import { ConfigurableProvidersService } from '@app/ui/auth/login/utilities/confi
|
||||||
import { LoginService } from '@app/ui/auth/login/utilities/login.service';
|
import { LoginService } from '@app/ui/auth/login/utilities/login.service';
|
||||||
import { CommonFormsModule } from '@common/forms/common-forms.module';
|
import { CommonFormsModule } from '@common/forms/common-forms.module';
|
||||||
import { CommonUiModule } from '@common/ui/common-ui.module';
|
import { CommonUiModule } from '@common/ui/common-ui.module';
|
||||||
|
import { MergeLoginService } from './utilities/merge-login.service';
|
||||||
import { ZenodoLoginComponent } from './zenodo-login/zenodo-login.component';
|
import { ZenodoLoginComponent } from './zenodo-login/zenodo-login.component';
|
||||||
|
|
||||||
@NgModule({
|
@NgModule({
|
||||||
|
@ -34,6 +35,6 @@ import { ZenodoLoginComponent } from './zenodo-login/zenodo-login.component';
|
||||||
exports: [
|
exports: [
|
||||||
LoginComponent
|
LoginComponent
|
||||||
],
|
],
|
||||||
providers: [LoginService, ConfigurableProvidersService]
|
providers: [LoginService, MergeLoginService, ConfigurableProvidersService]
|
||||||
})
|
})
|
||||||
export class LoginModule { }
|
export class LoginModule { }
|
||||||
|
|
|
@ -31,9 +31,10 @@ export class OpenAireLoginComponent extends BaseComponent implements OnInit {
|
||||||
this.route.queryParams
|
this.route.queryParams
|
||||||
.pipe(takeUntil(this._destroyed))
|
.pipe(takeUntil(this._destroyed))
|
||||||
.subscribe((params: Params) => {
|
.subscribe((params: Params) => {
|
||||||
const returnUrlFromParams = params['returnUrl'];
|
// const returnUrlFromParams = params['returnUrl'];
|
||||||
if (returnUrlFromParams) { this.returnUrl = returnUrlFromParams; }
|
// if (returnUrlFromParams) { this.returnUrl = returnUrlFromParams; }
|
||||||
if (!params['code']) { this.openaireAuthorize(); } else { this.openaireLoginUser(params['code'], params['state']) }
|
// if (!params['code']) { this.openaireAuthorize(); } else { this.openaireLoginUser(params['code'], params['state']) }
|
||||||
|
this.router.navigate(['/oauth2'], {queryParams: params});
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
import { HttpClient, HttpHeaders } from '@angular/common/http';
|
import { HttpClient, HttpHeaders } from '@angular/common/http';
|
||||||
import { Component, OnInit } from '@angular/core';
|
import { Component, OnInit } from '@angular/core';
|
||||||
import { FormControl } from '@angular/forms';
|
import { FormControl } from '@angular/forms';
|
||||||
import { ActivatedRoute, Params } from '@angular/router';
|
import { ActivatedRoute, Params, Router } from '@angular/router';
|
||||||
import { AuthProvider } from '@app/core/common/enum/auth-provider';
|
import { AuthProvider } from '@app/core/common/enum/auth-provider';
|
||||||
import { OrcidUser } from '@app/core/model/orcid/orcidUser';
|
import { OrcidUser } from '@app/core/model/orcid/orcidUser';
|
||||||
import { AuthService } from '@app/core/services/auth/auth.service';
|
import { AuthService } from '@app/core/services/auth/auth.service';
|
||||||
|
@ -28,7 +28,8 @@ export class OrcidLoginComponent extends BaseComponent implements OnInit {
|
||||||
private authService: AuthService,
|
private authService: AuthService,
|
||||||
private loginService: LoginService,
|
private loginService: LoginService,
|
||||||
private httpClient: HttpClient,
|
private httpClient: HttpClient,
|
||||||
private configurationService: ConfigurationService
|
private configurationService: ConfigurationService,
|
||||||
|
private router: Router
|
||||||
) {
|
) {
|
||||||
super();
|
super();
|
||||||
this.orcidUser = new OrcidUser;
|
this.orcidUser = new OrcidUser;
|
||||||
|
@ -38,9 +39,10 @@ export class OrcidLoginComponent extends BaseComponent implements OnInit {
|
||||||
this.route.queryParams
|
this.route.queryParams
|
||||||
.pipe(takeUntil(this._destroyed))
|
.pipe(takeUntil(this._destroyed))
|
||||||
.subscribe((params: Params) => {
|
.subscribe((params: Params) => {
|
||||||
const returnUrl = params['returnUrl'];
|
// const returnUrl = params['returnUrl'];
|
||||||
if (returnUrl) { this.returnUrl = returnUrl; }
|
// if (returnUrl) { this.returnUrl = returnUrl; }
|
||||||
if (!params['code']) { this.orcidAccessGetAuthCode(); } else { this.orcidLogin(params['code']); }
|
// if (!params['code']) { this.orcidAccessGetAuthCode(); } else { this.orcidLogin(params['code']); }
|
||||||
|
this.router.navigate(['/oauth2'], {queryParams: params});
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
import { HttpHeaders } from '@angular/common/http';
|
import { HttpHeaders } from '@angular/common/http';
|
||||||
import { Component, OnInit } from '@angular/core';
|
import { Component, OnInit } from '@angular/core';
|
||||||
import { ActivatedRoute, Params } from '@angular/router';
|
import { ActivatedRoute, Params, Router } from '@angular/router';
|
||||||
import { AuthProvider } from '@app/core/common/enum/auth-provider';
|
import { AuthProvider } from '@app/core/common/enum/auth-provider';
|
||||||
import { AuthService } from '@app/core/services/auth/auth.service';
|
import { AuthService } from '@app/core/services/auth/auth.service';
|
||||||
import { BaseHttpService } from '@app/core/services/http/base-http.service';
|
import { BaseHttpService } from '@app/core/services/http/base-http.service';
|
||||||
|
@ -26,7 +26,8 @@ export class TwitterLoginComponent extends BaseComponent implements OnInit {
|
||||||
private authService: AuthService,
|
private authService: AuthService,
|
||||||
private httpClient: BaseHttpService,
|
private httpClient: BaseHttpService,
|
||||||
private loginService: LoginService,
|
private loginService: LoginService,
|
||||||
private configurationService: ConfigurationService
|
private configurationService: ConfigurationService,
|
||||||
|
private router: Router
|
||||||
) {
|
) {
|
||||||
super();
|
super();
|
||||||
}
|
}
|
||||||
|
@ -35,9 +36,10 @@ export class TwitterLoginComponent extends BaseComponent implements OnInit {
|
||||||
this.route.queryParams
|
this.route.queryParams
|
||||||
.pipe(takeUntil(this._destroyed))
|
.pipe(takeUntil(this._destroyed))
|
||||||
.subscribe((params: Params) => {
|
.subscribe((params: Params) => {
|
||||||
const returnUrl = params['returnUrl'];
|
// const returnUrl = params['returnUrl'];
|
||||||
if (returnUrl) { this.returnUrl = returnUrl; }
|
// if (returnUrl) { this.returnUrl = returnUrl; }
|
||||||
if (!params['oauth_token'] && !params['oauth_verifier']) { this.twitterAuthorize(); } else { this.twitterLogin(params['oauth_token'], params['oauth_verifier']); }
|
// if (!params['oauth_token'] && !params['oauth_verifier']) { this.twitterAuthorize(); } else { this.twitterLogin(params['oauth_token'], params['oauth_verifier']); }
|
||||||
|
this.router.navigate(['/oauth2'], {queryParams: params});
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -0,0 +1,16 @@
|
||||||
|
import { Injectable } from '@angular/core';
|
||||||
|
import { UserMergeRequestModel } from '@app/core/model/merge/user-merge-request';
|
||||||
|
import { Observable, Subject } from 'rxjs';
|
||||||
|
|
||||||
|
@Injectable()
|
||||||
|
export class MergeLoginService {
|
||||||
|
private serviceStore = new Subject<UserMergeRequestModel>();
|
||||||
|
|
||||||
|
getObservable(): Observable<UserMergeRequestModel> {
|
||||||
|
return this.serviceStore.asObservable();
|
||||||
|
}
|
||||||
|
|
||||||
|
setRequest(request: UserMergeRequestModel) {
|
||||||
|
this.serviceStore.next(request);
|
||||||
|
}
|
||||||
|
}
|
|
@ -1,7 +1,7 @@
|
||||||
import { HttpClient, HttpHeaders } from '@angular/common/http';
|
import { HttpClient, HttpHeaders } from '@angular/common/http';
|
||||||
import { Component, OnInit } from '@angular/core';
|
import { Component, OnInit } from '@angular/core';
|
||||||
import { FormControl } from '@angular/forms';
|
import { FormControl } from '@angular/forms';
|
||||||
import { ActivatedRoute, Params } from '@angular/router';
|
import { ActivatedRoute, Params, Router } from '@angular/router';
|
||||||
import { AuthProvider } from '@app/core/common/enum/auth-provider';
|
import { AuthProvider } from '@app/core/common/enum/auth-provider';
|
||||||
import { OrcidUser } from '@app/core/model/orcid/orcidUser';
|
import { OrcidUser } from '@app/core/model/orcid/orcidUser';
|
||||||
import { AuthService } from '@app/core/services/auth/auth.service';
|
import { AuthService } from '@app/core/services/auth/auth.service';
|
||||||
|
@ -29,7 +29,8 @@ export class ZenodoLoginComponent extends BaseComponent implements OnInit {
|
||||||
private authService: AuthService,
|
private authService: AuthService,
|
||||||
private loginService: LoginService,
|
private loginService: LoginService,
|
||||||
private httpClient: HttpClient,
|
private httpClient: HttpClient,
|
||||||
private configurationService: ConfigurationService
|
private configurationService: ConfigurationService,
|
||||||
|
private router: Router
|
||||||
) {
|
) {
|
||||||
super();
|
super();
|
||||||
this.zenodoToken = new ZenodoToken;
|
this.zenodoToken = new ZenodoToken;
|
||||||
|
@ -39,9 +40,10 @@ export class ZenodoLoginComponent extends BaseComponent implements OnInit {
|
||||||
this.route.queryParams
|
this.route.queryParams
|
||||||
.pipe(takeUntil(this._destroyed))
|
.pipe(takeUntil(this._destroyed))
|
||||||
.subscribe((params: Params) => {
|
.subscribe((params: Params) => {
|
||||||
const returnUrl = params['returnUrl'];
|
// const returnUrl = params['returnUrl'];
|
||||||
if (returnUrl) { this.returnUrl = returnUrl; }
|
// if (returnUrl) { this.returnUrl = returnUrl; }
|
||||||
if (!params['code']) { this.zenodoAccessGetAuthCode(); } else { this.zenodoLogin(params['code']); }
|
// if (!params['code']) { this.zenodoAccessGetAuthCode(); } else { this.zenodoLogin(params['code']); }
|
||||||
|
this.router.navigate(['/oauth2'], {queryParams: params});
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -526,9 +526,9 @@ export class DmpOverviewComponent extends BaseComponent implements OnInit {
|
||||||
showOauth2Dialog(url: string, dmp: DmpOverviewModel) {
|
showOauth2Dialog(url: string, dmp: DmpOverviewModel) {
|
||||||
this.oauth2DialogService.login(url)
|
this.oauth2DialogService.login(url)
|
||||||
.pipe(takeUntil(this._destroyed))
|
.pipe(takeUntil(this._destroyed))
|
||||||
.subscribe(code => {
|
.subscribe(result => {
|
||||||
if (!isNullOrUndefined(code)) {
|
if (result.oauthCode !== undefined && result.oauthCode !== null) {
|
||||||
this.userService.registerDOIToken(code, this.configurationService.app + 'oauth2')
|
this.userService.registerDOIToken(result.oauthCode, this.configurationService.app + 'oauth2')
|
||||||
.pipe(takeUntil(this._destroyed))
|
.pipe(takeUntil(this._destroyed))
|
||||||
.subscribe(() => {
|
.subscribe(() => {
|
||||||
this.hasDOIToken = true;
|
this.hasDOIToken = true;
|
||||||
|
|
|
@ -24,7 +24,7 @@ export class Oauth2DialogComponent extends BaseComponent implements OnInit{
|
||||||
this.route.queryParams.pipe(takeUntil(this._destroyed))
|
this.route.queryParams.pipe(takeUntil(this._destroyed))
|
||||||
.subscribe((params: Params) => {
|
.subscribe((params: Params) => {
|
||||||
const url = params['url'];
|
const url = params['url'];
|
||||||
if (!params['code']) { this.loadUrl(url) } else { this.sendCode(params['code']); }
|
if (!params['code'] && (!params['oauth_token'] && !params['oauth_verifier'])) { this.loadUrl(url) } else { this.sendCode(params); }
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -32,8 +32,16 @@ export class Oauth2DialogComponent extends BaseComponent implements OnInit{
|
||||||
window.location.href = url;
|
window.location.href = url;
|
||||||
}
|
}
|
||||||
|
|
||||||
private sendCode(code: string) {
|
private sendCode(params: Params) {
|
||||||
localStorage.setItem('oauthCode', code);
|
if (params['code']) {
|
||||||
|
localStorage.setItem('oauthCode', params['code']);
|
||||||
|
}
|
||||||
|
if (params['state']) {
|
||||||
|
localStorage.setItem('oauthState', params['state']);
|
||||||
|
}
|
||||||
|
if (params['oauth_token'] && params['oauth_verifier']) {
|
||||||
|
localStorage.setItem('oauthObject', JSON.stringify({oauth_token: params['oauth_token'], oauth_verifier: params['oauth_verifier']}));
|
||||||
|
}
|
||||||
window.close();
|
window.close();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -8,7 +8,7 @@ import { takeUntil } from 'rxjs/operators';
|
||||||
@Injectable()
|
@Injectable()
|
||||||
export class Oauth2DialogService extends BaseService{
|
export class Oauth2DialogService extends BaseService{
|
||||||
|
|
||||||
private code: BehaviorSubject<string> = new BehaviorSubject(undefined);
|
private code: BehaviorSubject<any> = new BehaviorSubject(undefined);
|
||||||
|
|
||||||
constructor(private configurationService: ConfigurationService) {
|
constructor(private configurationService: ConfigurationService) {
|
||||||
super();
|
super();
|
||||||
|
@ -18,13 +18,29 @@ export class Oauth2DialogService extends BaseService{
|
||||||
this.code.next(code);
|
this.code.next(code);
|
||||||
}
|
}
|
||||||
|
|
||||||
public login(url: string): Observable<string> {
|
public login(url: string): Observable<any> {
|
||||||
const windows = window.open(this.configurationService.app + 'oauth2?url=' + encodeURIComponent(url) ,'', `height=500px,width=500px,top=${(window.screen.height / 2) - 200}px,left=${(window.screen.width / 2) - 200}px`);
|
const windows = window.open(this.configurationService.app + 'oauth2?url=' + encodeURIComponent(url) ,'', `height=500px,width=500px,top=${(window.screen.height / 2) - 200}px,left=${(window.screen.width / 2) - 200}px`);
|
||||||
const sub = interval(300).pipe(takeUntil(this._destroyed)).subscribe(() => {
|
const sub = interval(300).pipe(takeUntil(this._destroyed)).subscribe(() => {
|
||||||
if (windows.closed) {
|
if (windows.closed) {
|
||||||
const oauthCode = localStorage.getItem('oauthCode');
|
let oauthCode;
|
||||||
localStorage.removeItem('oauthCode');
|
let oauthState;
|
||||||
this.code.next(oauthCode);
|
let oauthToken;
|
||||||
|
let oauthVerifier;
|
||||||
|
if (localStorage.getItem('oauthCode')) {
|
||||||
|
oauthCode = localStorage.getItem('oauthCode');
|
||||||
|
localStorage.removeItem('oauthCode');
|
||||||
|
}
|
||||||
|
if (localStorage.getItem('oauthState')) {
|
||||||
|
oauthState = localStorage.getItem('oauthState');
|
||||||
|
localStorage.removeItem('oauthState');
|
||||||
|
}
|
||||||
|
if (localStorage.getItem('oauthObject')) {
|
||||||
|
const oauthObject = JSON.parse(localStorage.getItem('oauthObject'));
|
||||||
|
localStorage.removeItem('oauthObject');
|
||||||
|
oauthToken = oauthObject.oauth_token;
|
||||||
|
oauthVerifier = oauthObject.oauth_verifier;
|
||||||
|
}
|
||||||
|
this.code.next({oauthCode: oauthCode, oauthState: oauthState, oauthToken: oauthToken, oauthVerifier: oauthVerifier});
|
||||||
sub.unsubscribe();
|
sub.unsubscribe();
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
|
@ -3,16 +3,18 @@
|
||||||
<h1 mat-dialog-title class="title">{{'USER-PROFILE.ACTIONS.LINK-NEW-ACCOUNT' | translate}}</h1>
|
<h1 mat-dialog-title class="title">{{'USER-PROFILE.ACTIONS.LINK-NEW-ACCOUNT' | translate}}</h1>
|
||||||
<span class="ml-auto align-self-center" (click)="closeDialog()"><mat-icon class="close-icon">close</mat-icon></span>
|
<span class="ml-auto align-self-center" (click)="closeDialog()"><mat-icon class="close-icon">close</mat-icon></span>
|
||||||
</div>
|
</div>
|
||||||
<app-login [mergeUsers]="true"></app-login>
|
<app-login *ngIf="hasEmail" [mergeUsers]="true"></app-login>
|
||||||
<!-- <div mat-dialog-content class="definition-content pt-2">
|
<div *ngIf="!hasEmail">
|
||||||
<mat-form-field class="full-width">
|
<div mat-dialog-content class="definition-content pt-2">
|
||||||
<input matInput placeholder="{{'USER-PROFILE.SETTINGS.YOUR-EMAIL' | translate}}">
|
<mat-form-field class="full-width">
|
||||||
</mat-form-field>
|
<input matInput placeholder="{{'USER-PROFILE.SETTINGS.YOUR-EMAIL' | translate}}">
|
||||||
</div>
|
</mat-form-field>
|
||||||
<div mat-mat-dialog-actions>
|
|
||||||
<div class="col-auto d-flex pb-2 pt-2">
|
|
||||||
<button mat-raised-button type="button" class="cancel-btn ml-auto" (click)="cancel()">{{'USER-PROFILE.ACTIONS.CANCEL' | translate}}</button>
|
|
||||||
<button mat-raised-button type="button" class="add-btn ml-4" (click)="add()">{{'USER-PROFILE.ACTIONS.ADD' | translate}}</button>
|
|
||||||
</div>
|
</div>
|
||||||
</div> -->
|
<div mat-mat-dialog-actions>
|
||||||
|
<div class="col-auto d-flex pb-2 pt-2">
|
||||||
|
<button mat-raised-button type="button" class="cancel-btn ml-auto" (click)="cancel()">{{'USER-PROFILE.ACTIONS.CANCEL' | translate}}</button>
|
||||||
|
<button mat-raised-button type="button" class="add-btn ml-4" (click)="add()">{{'USER-PROFILE.ACTIONS.ADD' | translate}}</button>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
|
@ -1,6 +1,8 @@
|
||||||
import { Component, Inject, OnInit } from '@angular/core';
|
import { Component, Inject, OnInit } from '@angular/core';
|
||||||
import { FormGroup } from '@angular/forms';
|
import { FormGroup } from '@angular/forms';
|
||||||
import { MatDialogRef, MAT_DIALOG_DATA } from '@angular/material/dialog';
|
import { MatDialogRef, MAT_DIALOG_DATA } from '@angular/material/dialog';
|
||||||
|
import { UserMergeRequestModel } from '@app/core/model/merge/user-merge-request';
|
||||||
|
import { MergeLoginService } from '@app/ui/auth/login/utilities/merge-login.service';
|
||||||
import { DatasetDescriptionFormEditorModel } from '@app/ui/misc/dataset-description-form/dataset-description-form.model';
|
import { DatasetDescriptionFormEditorModel } from '@app/ui/misc/dataset-description-form/dataset-description-form.model';
|
||||||
|
|
||||||
@Component({
|
@Component({
|
||||||
|
@ -13,8 +15,11 @@ export class AddAccountDialogComponent implements OnInit {
|
||||||
datasetProfileDefinitionModel: DatasetDescriptionFormEditorModel;
|
datasetProfileDefinitionModel: DatasetDescriptionFormEditorModel;
|
||||||
datasetProfileDefinitionFormGroup: FormGroup;
|
datasetProfileDefinitionFormGroup: FormGroup;
|
||||||
progressIndication = false;
|
progressIndication = false;
|
||||||
|
public hasEmail = true;
|
||||||
|
private request: UserMergeRequestModel;
|
||||||
|
|
||||||
constructor(
|
constructor(
|
||||||
|
private mergeLoginService: MergeLoginService,
|
||||||
public dialogRef: MatDialogRef<AddAccountDialogComponent>,
|
public dialogRef: MatDialogRef<AddAccountDialogComponent>,
|
||||||
@Inject(MAT_DIALOG_DATA) public data: any
|
@Inject(MAT_DIALOG_DATA) public data: any
|
||||||
) {
|
) {
|
||||||
|
@ -22,11 +27,21 @@ export class AddAccountDialogComponent implements OnInit {
|
||||||
}
|
}
|
||||||
|
|
||||||
ngOnInit(): void {
|
ngOnInit(): void {
|
||||||
|
this.mergeLoginService.getObservable().subscribe(result => {
|
||||||
|
if (result !== undefined) {
|
||||||
|
if (!(result.email !== undefined && result.email !== null)) {
|
||||||
|
this.request = result;
|
||||||
|
this.hasEmail = false;
|
||||||
|
} else {
|
||||||
|
this.dialogRef.close(result);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
add(): void {
|
add(): void {
|
||||||
this.dialogRef.close(true);
|
this.request.email = 'email';
|
||||||
|
this.dialogRef.close(this.request);
|
||||||
}
|
}
|
||||||
|
|
||||||
cancel(): void {
|
cancel(): void {
|
||||||
|
|
|
@ -26,6 +26,7 @@ import { AddAccountDialogComponent } from './add-account/add-account-dialog.comp
|
||||||
import { MatDialog } from '@angular/material';
|
import { MatDialog } from '@angular/material';
|
||||||
import { UserCredentialModel } from '@app/core/model/user/user-credential';
|
import { UserCredentialModel } from '@app/core/model/user/user-credential';
|
||||||
import { AuthProvider } from '@app/core/common/enum/auth-provider';
|
import { AuthProvider } from '@app/core/common/enum/auth-provider';
|
||||||
|
import { MergeEmailConfirmationService } from '@app/core/services/merge-email-confirmation/merge-email-confirmation.service';
|
||||||
|
|
||||||
const availableLanguages: any[] = require('../../../assets/resources/language.json');
|
const availableLanguages: any[] = require('../../../assets/resources/language.json');
|
||||||
|
|
||||||
|
@ -71,7 +72,8 @@ export class UserProfileComponent extends BaseComponent implements OnInit, OnDes
|
||||||
private configurationService: ConfigurationService,
|
private configurationService: ConfigurationService,
|
||||||
private oauth2DialogService: Oauth2DialogService,
|
private oauth2DialogService: Oauth2DialogService,
|
||||||
private dialog: MatDialog,
|
private dialog: MatDialog,
|
||||||
public enumUtils: EnumUtils
|
public enumUtils: EnumUtils,
|
||||||
|
private mergeEmailConfirmation: MergeEmailConfirmationService
|
||||||
) { super(); }
|
) { super(); }
|
||||||
|
|
||||||
ngOnInit() {
|
ngOnInit() {
|
||||||
|
@ -234,9 +236,9 @@ export class UserProfileComponent extends BaseComponent implements OnInit, OnDes
|
||||||
showOauth2Dialog(url: string) {
|
showOauth2Dialog(url: string) {
|
||||||
this.oauth2DialogService.login(url)
|
this.oauth2DialogService.login(url)
|
||||||
.pipe(takeUntil(this._destroyed))
|
.pipe(takeUntil(this._destroyed))
|
||||||
.subscribe(code => {
|
.subscribe(result => {
|
||||||
if (!isNullOrUndefined(code)) {
|
if (result.oauthCode !== undefined && result.oauthCode !== null) {
|
||||||
this.userService.registerDOIToken(code, this.configurationService.app + 'oauth2')
|
this.userService.registerDOIToken(result.oauthCode, this.configurationService.app + 'oauth2')
|
||||||
.pipe(takeUntil(this._destroyed))
|
.pipe(takeUntil(this._destroyed))
|
||||||
.subscribe(() => this.router.navigate(['/reload']).then(() => this.router.navigate(['/profile'])));
|
.subscribe(() => this.router.navigate(['/reload']).then(() => this.router.navigate(['/profile'])));
|
||||||
}
|
}
|
||||||
|
@ -263,6 +265,7 @@ export class UserProfileComponent extends BaseComponent implements OnInit, OnDes
|
||||||
});
|
});
|
||||||
dialogRef.afterClosed().pipe(takeUntil(this._destroyed)).subscribe(result => {
|
dialogRef.afterClosed().pipe(takeUntil(this._destroyed)).subscribe(result => {
|
||||||
if (result) {
|
if (result) {
|
||||||
|
this.mergeEmailConfirmation.sendConfirmationEmail(result);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue