Facebook login app frontend
This commit is contained in:
@@ -66,7 +66,7 @@
|
||||
<ion-label class="or">Or Continue With</ion-label>
|
||||
<div class="button">
|
||||
<ion-buttons>
|
||||
<ion-button>
|
||||
<ion-button (click) ="onLoginFacebook()">
|
||||
<ion-icon name="logo-facebook"></ion-icon>
|
||||
</ion-button>
|
||||
</ion-buttons>
|
||||
|
||||
@@ -13,6 +13,10 @@ import {
|
||||
SignInWithAppleResponse,
|
||||
SignInWithAppleOptions,
|
||||
} from '@capacitor-community/apple-sign-in';
|
||||
import {
|
||||
FacebookLogin,
|
||||
FacebookLoginResponse,
|
||||
} from '@capacitor-community/facebook-login';
|
||||
|
||||
@Component({
|
||||
selector: 'app-login',
|
||||
@@ -52,6 +56,8 @@ export class LoginPage implements OnInit {
|
||||
//console.log(`Hello ${value}!`);
|
||||
};
|
||||
|
||||
// use hook after platform dom ready
|
||||
FacebookLogin.initialize({ appId: environment.facebookAppId });
|
||||
}
|
||||
|
||||
getBlogData(){
|
||||
@@ -109,6 +115,70 @@ getBlogData(){
|
||||
this.router.navigate(['startscan']);
|
||||
}
|
||||
|
||||
onLoginFacebook() {
|
||||
const FACEBOOK_PERMISSIONS = [
|
||||
'email',
|
||||
'user_birthday',
|
||||
'user_photos',
|
||||
'user_gender',
|
||||
];
|
||||
|
||||
FacebookLogin.login({
|
||||
permissions: FACEBOOK_PERMISSIONS
|
||||
}).then((result: FacebookLoginResponse) => {
|
||||
if (result.accessToken) {
|
||||
// Login successful.
|
||||
console.log(result);
|
||||
console.log(`Facebook access token is ${result.accessToken.token}`);
|
||||
|
||||
/*
|
||||
var reqData = {
|
||||
auth_type: "FACEBOOK",
|
||||
code: codeResponse,
|
||||
redirect_uri: process.env.REACT_APP_FACEBOOK_REDIRECT_URL,
|
||||
};
|
||||
*/
|
||||
const oauth2Data = {
|
||||
"auth_type": "FACEBOOK",
|
||||
"access_token": result.accessToken.token,
|
||||
"user":result.accessToken.userId,
|
||||
"application_id":result.accessToken.applicationId,
|
||||
};
|
||||
console.log(oauth2Data);
|
||||
// Validate token with server and create new session
|
||||
this.wrenchService.authStart(oauth2Data).subscribe(
|
||||
loginResult => {
|
||||
console.log(loginResult);
|
||||
this.loginResult = loginResult;
|
||||
console.log("INTERNAL RETURN->" + this.loginResult.internal_return);
|
||||
|
||||
if (loginResult != null && loginResult.internal_return == 100 && this.sessionDataProviderService.ConstructGlobalSessionData(this.loginResult) == true) {
|
||||
const setName = async () => {
|
||||
await Preferences.set({
|
||||
key: 'username',
|
||||
value: this.username,
|
||||
});
|
||||
};
|
||||
|
||||
this.getBlogData();
|
||||
this.router.navigate(['tabs/tab1']);
|
||||
}
|
||||
else{
|
||||
this.showAlert("Error","Invalid username/password");
|
||||
}
|
||||
}
|
||||
);
|
||||
|
||||
} else {
|
||||
console.log(result);
|
||||
this.showAlert("Error", "Login failed!");
|
||||
}
|
||||
}).catch((error: any) => {
|
||||
this.showAlert("Error", error);
|
||||
console.log(error);
|
||||
});
|
||||
}
|
||||
|
||||
onLoginApple() {
|
||||
|
||||
// -> 'web', 'ios' or 'android'
|
||||
|
||||
@@ -1,8 +1,9 @@
|
||||
export const environment = {
|
||||
production: true,
|
||||
apiKey: '', // <-- Enter your own key here!' PROD
|
||||
baseUrl: 'https://apigate.nebula.g1.wrenchboard.com/svs/user',
|
||||
images: 'https://apigate.nebula.g1.wrenchboard.com/svs/user',
|
||||
appleRedirectUri: '',
|
||||
baseUrl: 'https://apigate.lotus.g1.wrenchboard.com/svs/user',
|
||||
images: 'https://apigate.lotus.g1.wrenchboard.com/svs/user',
|
||||
appleRedirectUri: 'https://users.wrenchboard.com/loginWithApple',
|
||||
facebookAppId: '390204307987009',
|
||||
loginSocial: false
|
||||
};
|
||||
|
||||
@@ -1,9 +1,10 @@
|
||||
export const environment = {
|
||||
production: false,
|
||||
apiKey: '', // <-- Enter your own key here!' TEST
|
||||
baseUrl: 'https://apigate.nebula.g1.wrenchboard.com/en/wrench/api/v1',
|
||||
images: 'https://apigate.nebula.g1.wrenchboard.com/en/wrench/api/v1/',
|
||||
baseUrl: 'https://apigate.lotus.g1.wrenchboard.com/en/wrench/api/v1',
|
||||
images: 'https://apigate.lotus.g1.wrenchboard.com/en/wrench/api/v1/',
|
||||
appleRedirectUri: 'https://dev-users.wrenchboard.com/loginWithApple',
|
||||
facebookAppId: '677857427521030',
|
||||
loginSocial: true
|
||||
};
|
||||
|
||||
|
||||
Reference in New Issue
Block a user