Commit f9fda747 by Muhammad Usman

social login added

parent b31b005b
......@@ -36,12 +36,12 @@
<div class="d-flex justify-content-center">
<button class="action-btn google-login" (click)="socicalMediaLogin('google')" [disabled]="isLoading">Sign in with Google</button>
<button class="action-btn google-login" (click)="socialMediaLogin('google')" [disabled]="isLoading">Sign in with Google</button>
</div>
<div class="d-flex justify-content-center">
<button class="action-btn linkedin-login" (click)="socicalMediaLogin('linkedIn')" [disabled]="isLoading">Sign in with Linkedin</button>
<button class="action-btn linkedin-login" (click)="socialMediaLogin('linkedIn')" [disabled]="isLoading">Sign in with Linkedin</button>
</div>
</form>
</div>
......
import { Component, ViewChild } from '@angular/core';
import { NgForm } from '@angular/forms';
import { Router } from '@angular/router';
import { Subscription } from 'rxjs';
import { takeUntil } from 'rxjs/operators';
import { environment } from '../../../../../environments/environment';
import { AppService } from '../../../../app.service';
......@@ -18,7 +17,6 @@ import { HelperService } from '../../services/helper.service';
export class LoginComponent extends BaseComponent {
year = new Date().getFullYear();
subscriptions: Array<Subscription> = [];
loginForm = {
username: '',
......@@ -30,7 +28,7 @@ export class LoginComponent extends BaseComponent {
private hs: HelperService,
private as: AuthService,
private r: Router,
private appService: AppService
private aps: AppService
) {
super();
}
......@@ -57,57 +55,27 @@ export class LoginComponent extends BaseComponent {
});
}
googleLogin(): void {
this.isLoading = true;
this.as.googleLogin()
.pipe(takeUntil(this.componentInView))
.subscribe(response => {
this.hs.oneItHttpResponse(response);
// if (response.status === 'error') {
// this.loginForm.password = '';
// }
this.isLoading = false;
}, err => {
this.hs.handleHttpError(err);
this.isLoading = false;
});
}
linkedInLogin(): void {
this.isLoading = true;
this.as.linkedinLogin()
.pipe(takeUntil(this.componentInView))
.subscribe(response => {
this.hs.oneItHttpResponse(response);
// if (response.status === 'error') {
// this.loginForm.password = '';
// }
this.isLoading = false;
}, err => {
this.hs.handleHttpError(err);
this.isLoading = false;
});
}
socicalMediaLogin(type : string) {
socialMediaLogin(type: 'google' | 'linkedIn') {
const params = {
environment: environment.envName,
nextPage: window.location.href.split('/#/')[0] + '/#/my-career-web/dashboard/home'
};
const svc = type === 'linkedIn' ? 'LoginWithLinkedIn' : 'LoginWithGoogle';
this.subscriptions.push(this.appService.socicalMediaLogin(svc,params)
.subscribe(
data => {
this.isLoading = true;
this.aps.socicalMediaLogin(svc, params)
.pipe(takeUntil(this.componentInView))
.subscribe(data => {
this.isLoading = false;
if (data.destination) {
window.location.href = data.destination;
return;
}
},
error => {
err => {
this.hs.handleHttpError(err);
this.isLoading = false;
}
)
);
}
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment