Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: change signatures of signOut methods to fix TS errors #427

Merged
merged 1 commit into from
Jul 1, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion projects/lib/src/providers/dummy-login-provider.ts
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@ export class DummyLoginProvider extends BaseLoginProvider {
});
}

signOut(revoke?: boolean): Promise<any> {
signOut(revoke?: boolean): Promise<void> {
return new Promise((resolve, reject) => {
this.loggedIn = false;
resolve();
Expand Down
34 changes: 20 additions & 14 deletions projects/lib/src/providers/facebook-login-provider.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,31 +6,35 @@ declare let FB: any;
export class FacebookLoginProvider extends BaseLoginProvider {
public static readonly PROVIDER_ID: string = 'FACEBOOK';

constructor(
private clientId: string,
private initOptions: any = {
scope: 'email,public_profile',
locale: 'en_US',
fields: 'name,email,picture,first_name,last_name',
version: 'v4.0',
}
) {
private requestOptions = {
scope: 'email,public_profile',
locale: 'en_US',
fields: 'name,email,picture,first_name,last_name',
version: 'v10.0',
};

constructor(private clientId: string, initOptions: Object = {}) {
super();

this.requestOptions = {
...this.requestOptions,
...initOptions,
};
}

initialize(): Promise<void> {
return new Promise((resolve, reject) => {
try {
this.loadScript(
FacebookLoginProvider.PROVIDER_ID,
`//connect.facebook.net/${this.initOptions.locale}/sdk.js`,
`//connect.facebook.net/${this.requestOptions.locale}/sdk.js`,
() => {
FB.init({
appId: this.clientId,
autoLogAppEvents: true,
cookie: true,
xfbml: true,
version: this.initOptions.version,
version: this.requestOptions.version,
});

resolve();
Expand All @@ -47,7 +51,7 @@ export class FacebookLoginProvider extends BaseLoginProvider {
FB.getLoginStatus((response: any) => {
if (response.status === 'connected') {
let authResponse = response.authResponse;
FB.api(`/me?fields=${this.initOptions.fields}`, (fbUser: any) => {
FB.api(`/me?fields=${this.requestOptions.fields}`, (fbUser: any) => {
let user: SocialUser = new SocialUser();

user.id = fbUser.id;
Expand All @@ -67,14 +71,16 @@ export class FacebookLoginProvider extends BaseLoginProvider {
resolve(user);
});
} else {
reject(`No user is currently logged in with ${FacebookLoginProvider.PROVIDER_ID}`);
reject(
`No user is currently logged in with ${FacebookLoginProvider.PROVIDER_ID}`
);
}
});
});
}

signIn(signInOptions?: any): Promise<SocialUser> {
const options = { ...this.initOptions, ...signInOptions };
const options = { ...this.requestOptions, ...signInOptions };
return new Promise((resolve, reject) => {
FB.login((response: any) => {
if (response.authResponse) {
Expand Down
2 changes: 1 addition & 1 deletion projects/lib/src/providers/microsoft-login-provider.ts
Original file line number Diff line number Diff line change
Expand Up @@ -210,7 +210,7 @@ export class MicrosoftLoginProvider extends BaseLoginProvider {
return await this.getSocialUser(loginResponse);
}

async signOut(revoke?: boolean): Promise<any> {
async signOut(revoke?: boolean): Promise<void> {
const accounts = this._instance.getAllAccounts();
if (accounts?.length > 0) {
await this._instance.logoutPopup({
Expand Down