Improve Oauth2 Dialog
This commit is contained in:
parent
6542841c6c
commit
2c94cfa130
|
@ -6,7 +6,6 @@ import { AuthService } from '@app/core/services/auth/auth.service';
|
|||
import { ConfigurableProvidersService } from '@app/ui/auth/login/utilities/configurableProviders.service';
|
||||
import { LoginService } from '@app/ui/auth/login/utilities/login.service';
|
||||
import { BaseComponent } from '@common/base/base.component';
|
||||
import { environment } from 'environments/environment';
|
||||
import { takeUntil } from 'rxjs/operators';
|
||||
import { ConfigurationService } from '@app/core/services/configuration/configuration.service';
|
||||
import { MergeLoginService } from './utilities/merge-login.service';
|
||||
|
@ -251,11 +250,11 @@ export class LoginComponent extends BaseComponent implements OnInit, AfterViewIn
|
|||
client_id: this.configurationService.loginProviders.googleConfiguration.clientId,
|
||||
scope: 'profile email'
|
||||
});
|
||||
this.attachGoogleSignΙn(document.getElementById('googleSignInButton'));
|
||||
this.attachGoogleSignIn(document.getElementById('googleSignInButton'));
|
||||
});
|
||||
}
|
||||
|
||||
public attachGoogleSignΙn(element) {
|
||||
public attachGoogleSignIn(element) {
|
||||
if (!element) { return; }
|
||||
this.auth2.attachClickHandler(element, {},
|
||||
(googleUser) => {
|
||||
|
|
|
@ -33,15 +33,13 @@ export class Oauth2DialogComponent extends BaseComponent implements OnInit{
|
|||
}
|
||||
|
||||
private sendCode(params: Params) {
|
||||
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']}));
|
||||
}
|
||||
const oauthObject = {
|
||||
oauthCode: params['code'] ? params['code'] : undefined,
|
||||
oauthState: params['state'] ? params['state'] : undefined,
|
||||
oauthToken: params['oauth_token'] ? params['oath_token'] : undefined,
|
||||
oauthVerifier: params['oauth_verifier'] ? params['oauth_verifier'] : undefined
|
||||
};
|
||||
localStorage.setItem('arglogRes', JSON.stringify({response: { date: new Date(), data: oauthObject }}));
|
||||
window.close();
|
||||
}
|
||||
|
||||
|
|
|
@ -14,7 +14,7 @@ export class Oauth2DialogService extends BaseService{
|
|||
super();
|
||||
}
|
||||
|
||||
public registerCode(code: string) {
|
||||
public registerCode(code: any) {
|
||||
this.code.next(code);
|
||||
}
|
||||
|
||||
|
@ -22,26 +22,14 @@ export class Oauth2DialogService extends BaseService{
|
|||
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(() => {
|
||||
if (windows.closed) {
|
||||
let oauthCode;
|
||||
let oauthState;
|
||||
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});
|
||||
if (localStorage.getItem('arglogRes')) {
|
||||
const oauthResponse = JSON.parse(localStorage.getItem('arglogRes'));
|
||||
localStorage.removeItem('arglogRes');
|
||||
const oauthObject = oauthResponse.response.data;
|
||||
this.code.next(oauthObject);
|
||||
this.code.next(undefined);
|
||||
}
|
||||
|
||||
sub.unsubscribe();
|
||||
}
|
||||
});
|
||||
|
|
|
@ -1,40 +0,0 @@
|
|||
export const environment = {
|
||||
production: true,
|
||||
Server: 'https://devel.opendmp.eu/srv/api/',
|
||||
App: 'https://devel.opendmp.eu/',
|
||||
HelpService: {
|
||||
Enabled: false,
|
||||
Url: 'https://devel.opendmp.eu/content-service/',
|
||||
},
|
||||
defaultCulture: 'en-US',
|
||||
loginProviders: {
|
||||
enabled: [1, 2, 3, 4, 5, 6],
|
||||
facebookConfiguration: { clientId: '' },
|
||||
googleConfiguration: { clientId: '' },
|
||||
linkedInConfiguration: {
|
||||
clientId: '',
|
||||
oauthUrl: 'https://www.linkedin.com/oauth/v2/authorization',
|
||||
redirectUri: 'http://localhost:4200/login/linkedin',
|
||||
state: ''
|
||||
},
|
||||
twitterConfiguration: {
|
||||
clientId: '',
|
||||
oauthUrl: 'https://api.twitter.com/oauth/authenticate'
|
||||
},
|
||||
b2accessConfiguration: {
|
||||
clientId: '',
|
||||
oauthUrl: 'https://b2access-integration.fz-juelich.de:443/oauth2-as/oauth2-authz',
|
||||
redirectUri: 'http://opendmp.eu/api/oauth/authorized/b2access',
|
||||
state: ''
|
||||
},
|
||||
orcidConfiguration: {
|
||||
clientId: 'APP-766DI5LP8T75FC4R',
|
||||
oauthUrl: 'https://sandbox.orcid.org/oauth/authorize',
|
||||
redirectUri: 'http://opendmp.eu/api/oauth/authorized/orcid'
|
||||
}
|
||||
},
|
||||
logging: {
|
||||
enabled: false,
|
||||
logLevels: ["debug", "info", "warning", "error"]
|
||||
},
|
||||
};
|
|
@ -1,40 +0,0 @@
|
|||
export const environment = {
|
||||
production: true,
|
||||
Server: 'https://devel.opendmp.eu/srv/api/',
|
||||
App: 'https://devel.opendmp.eu/',
|
||||
HelpService: {
|
||||
Enabled: false,
|
||||
Url: 'https://devel.opendmp.eu/content-service/',
|
||||
},
|
||||
defaultCulture: 'en-US',
|
||||
loginProviders: {
|
||||
enabled: [1, 2, 3, 4, 5, 6],
|
||||
facebookConfiguration: { clientId: '' },
|
||||
googleConfiguration: { clientId: '596924546661-83nhl986pnrpug5h624i5kptuao03dcd.apps.googleusercontent.com' },
|
||||
linkedInConfiguration: {
|
||||
clientId: '',
|
||||
oauthUrl: 'https://www.linkedin.com/oauth/v2/authorization',
|
||||
redirectUri: 'https://devel.opendmp.eu/login/linkedin',
|
||||
state: ''
|
||||
},
|
||||
twitterConfiguration: {
|
||||
clientId: '',
|
||||
oauthUrl: 'https://api.twitter.com/oauth/authenticate'
|
||||
},
|
||||
b2accessConfiguration: {
|
||||
clientId: '',
|
||||
oauthUrl: 'https://b2access-integration.fz-juelich.de:443/oauth2-as/oauth2-authz',
|
||||
redirectUri: 'http://devel.opendmp.eu/api/oauth/authorized/b2access',
|
||||
state: ''
|
||||
},
|
||||
orcidConfiguration: {
|
||||
clientId: '',
|
||||
oauthUrl: 'https://sandbox.orcid.org/oauth/authorize',
|
||||
redirectUri: 'http://opendmp.eu/api/oauth/authorized/orcid'
|
||||
}
|
||||
},
|
||||
logging: {
|
||||
enabled: false,
|
||||
logLevels: ["debug", "info", "warning", "error"]
|
||||
},
|
||||
};
|
|
@ -1,48 +1,3 @@
|
|||
export const environment = {
|
||||
production: false,
|
||||
Server: 'http://localhost:8080/api/',
|
||||
App: 'http://localhost:4200/',
|
||||
HelpService: {
|
||||
Enabled: false,
|
||||
Url: 'localhost:5000/',
|
||||
},
|
||||
defaultCulture: 'en-US',
|
||||
loginProviders: {
|
||||
enabled: [1, 2, 3, 4, 5, 6, 7, 8],
|
||||
facebookConfiguration: { clientId: '' },
|
||||
googleConfiguration: { clientId: '' },
|
||||
linkedInConfiguration: {
|
||||
clientId: '',
|
||||
oauthUrl: 'https://www.linkedin.com/oauth/v2/authorization',
|
||||
redirectUri: 'http://localhost:4200/login/linkedin',
|
||||
state: '987654321'
|
||||
},
|
||||
twitterConfiguration: {
|
||||
clientId: '',
|
||||
oauthUrl: 'https://api.twitter.com/oauth/authenticate'
|
||||
},
|
||||
b2accessConfiguration: {
|
||||
clientId: '',
|
||||
oauthUrl: 'https://b2access-integration.fz-juelich.de:443/oauth2-as/oauth2-authz',
|
||||
redirectUri: 'http://localhost:4200/api/oauth/authorized/b2access',
|
||||
state: ''
|
||||
},
|
||||
orcidConfiguration: {
|
||||
clientId: 'APP-766DI5LP8T75FC4R',
|
||||
oauthUrl: 'https://orcid.org/oauth/authorize',
|
||||
redirectUri: 'http://localhost:4200/login/external/orcid'
|
||||
},
|
||||
openAireConfiguration: {
|
||||
clientId: '',
|
||||
oauthUrl: '',
|
||||
redirectUri: '',
|
||||
state: '987654321'
|
||||
}
|
||||
},
|
||||
logging: {
|
||||
enabled: true,
|
||||
logLevels: ["debug", "info", "warning", "error"]
|
||||
},
|
||||
lockInterval: 60000,
|
||||
guideAssets: "assets/images/guide"
|
||||
production: false
|
||||
};
|
||||
|
|
Loading…
Reference in New Issue