Google Login frontend
This commit is contained in:
@@ -17,6 +17,7 @@ dependencies {
|
||||
implementation project(':capacitor-keyboard')
|
||||
implementation project(':capacitor-preferences')
|
||||
implementation project(':capacitor-status-bar')
|
||||
implementation project(':codetrix-studio-capacitor-google-auth')
|
||||
implementation "com.onesignal:OneSignal:5.0.0-beta4"
|
||||
implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk7:1.7.10"
|
||||
}
|
||||
|
||||
@@ -6,4 +6,5 @@
|
||||
<string name="custom_url_scheme">com.wrenchboard.users</string>
|
||||
<string name="facebook_app_id">390204307987009</string>
|
||||
<string name="facebook_client_token">70e8f7ea883417e96f137e0bd025bfce</string>
|
||||
<string name="server_client_id">817021856543-ad9nsjgdpsu2s2jrl63j3ihrv7lbf6ma.apps.googleusercontent.com</string>
|
||||
</resources>
|
||||
|
||||
@@ -25,3 +25,6 @@ project(':capacitor-preferences').projectDir = new File('../node_modules/@capaci
|
||||
|
||||
include ':capacitor-status-bar'
|
||||
project(':capacitor-status-bar').projectDir = new File('../node_modules/@capacitor/status-bar/android')
|
||||
|
||||
include ':codetrix-studio-capacitor-google-auth'
|
||||
project(':codetrix-studio-capacitor-google-auth').projectDir = new File('../node_modules/@codetrix-studio/capacitor-google-auth/android')
|
||||
|
||||
@@ -0,0 +1,14 @@
|
||||
{
|
||||
"appId": "com.wrenchboard.users",
|
||||
"appName": "WrenchBoard",
|
||||
"webDir": "www",
|
||||
"bundledWebRuntime": false,
|
||||
"plugins": {
|
||||
"GoogleAuth": {
|
||||
"scopes": ["profile","email"],
|
||||
"clientId": "817021856543-ad9nsjgdpsu2s2jrl63j3ihrv7lbf6ma.apps.googleusercontent.com",
|
||||
"serverClientId": "817021856543-ad9nsjgdpsu2s2jrl63j3ihrv7lbf6ma.apps.googleusercontent.com",
|
||||
"forceCodeForRefreshToken": true
|
||||
}
|
||||
}
|
||||
}
|
||||
+9
-1
@@ -4,7 +4,15 @@ const config: CapacitorConfig = {
|
||||
appId: 'com.wrenchboard.users',
|
||||
appName: 'WrenchBoard',
|
||||
webDir: 'www',
|
||||
bundledWebRuntime: false
|
||||
bundledWebRuntime: false,
|
||||
plugins: {
|
||||
GoogleAuth: {
|
||||
scopes: ['profile', 'email'],
|
||||
clientId: '817021856543-ad9nsjgdpsu2s2jrl63j3ihrv7lbf6ma.apps.googleusercontent.com',
|
||||
serverClientId: '817021856543-ad9nsjgdpsu2s2jrl63j3ihrv7lbf6ma.apps.googleusercontent.com',
|
||||
forceCodeForRefreshToken: true,
|
||||
},
|
||||
},
|
||||
};
|
||||
|
||||
export default config;
|
||||
|
||||
@@ -2,8 +2,6 @@
|
||||
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
|
||||
<plist version="1.0">
|
||||
<dict>
|
||||
<key>NSCameraUsageDescription</key>
|
||||
<string>Scan QR Code to login</string>
|
||||
<key>CFBundleDevelopmentRegion</key>
|
||||
<string>en</string>
|
||||
<key>CFBundleDisplayName</key>
|
||||
@@ -25,18 +23,19 @@
|
||||
<dict>
|
||||
<key>CFBundleURLSchemes</key>
|
||||
<array>
|
||||
<string>fb677857427521030</string>
|
||||
<string>fb390204307987009</string>
|
||||
<string>com.googleusercontent.apps.817021856543-ad9nsjgdpsu2s2jrl63j3ihrv7lbf6ma</string>
|
||||
</array>
|
||||
</dict>
|
||||
</array>
|
||||
<key>CFBundleVersion</key>
|
||||
<string>$(CURRENT_PROJECT_VERSION)</string>
|
||||
<key>FacebookAppID</key>
|
||||
<string>677857427521030</string>
|
||||
<string>390204307987009</string>
|
||||
<key>FacebookClientToken</key>
|
||||
<string>a6fb48571d9dd9fe5f3454b1ae2401e2</string>
|
||||
<string>70e8f7ea883417e96f137e0bd025bfce</string>
|
||||
<key>FacebookDisplayName</key>
|
||||
<string>wrenchboard.com - development</string>
|
||||
<string>WrenchBoard</string>
|
||||
<key>LSApplicationQueriesSchemes</key>
|
||||
<array>
|
||||
<string>fbapi</string>
|
||||
@@ -57,6 +56,8 @@
|
||||
</array>
|
||||
<key>LSRequiresIPhoneOS</key>
|
||||
<true/>
|
||||
<key>NSCameraUsageDescription</key>
|
||||
<string>Scan QR Code to login</string>
|
||||
<key>NSLocationAlwaysAndWhenInUseUsageDescription</key>
|
||||
<string>We need to enable geotagging to send you notifications and messages based on your location, so you will get the relevant ones only</string>
|
||||
<key>NSLocationAlwaysUsageDescription</key>
|
||||
|
||||
@@ -8,6 +8,8 @@ use_frameworks!
|
||||
# Requires CocoaPods 1.6 or newer
|
||||
install! 'cocoapods', :disable_input_output_paths => true
|
||||
|
||||
gem 'activesupport', '~> 7.0', '<= 7.0.8'
|
||||
|
||||
def capacitor_pods
|
||||
pod 'Capacitor', :path => '../../node_modules/@capacitor/ios'
|
||||
pod 'CapacitorCordova', :path => '../../node_modules/@capacitor/ios'
|
||||
@@ -19,6 +21,7 @@ def capacitor_pods
|
||||
pod 'CapacitorKeyboard', :path => '../../node_modules/@capacitor/keyboard'
|
||||
pod 'CapacitorPreferences', :path => '../../node_modules/@capacitor/preferences'
|
||||
pod 'CapacitorStatusBar', :path => '../../node_modules/@capacitor/status-bar'
|
||||
pod 'CodetrixStudioCapacitorGoogleAuth', :path => '../../node_modules/@codetrix-studio/capacitor-google-auth'
|
||||
pod 'CordovaPluginsStatic', :path => '../capacitor-cordova-ios-plugins'
|
||||
end
|
||||
|
||||
|
||||
+31
-2
@@ -1,4 +1,10 @@
|
||||
PODS:
|
||||
- AppAuth (1.6.2):
|
||||
- AppAuth/Core (= 1.6.2)
|
||||
- AppAuth/ExternalUserAgent (= 1.6.2)
|
||||
- AppAuth/Core (1.6.2)
|
||||
- AppAuth/ExternalUserAgent (1.6.2):
|
||||
- AppAuth/Core
|
||||
- Capacitor (5.0.5):
|
||||
- CapacitorCordova
|
||||
- CapacitorApp (5.0.3):
|
||||
@@ -20,6 +26,9 @@ PODS:
|
||||
- Capacitor
|
||||
- CapacitorStatusBar (5.0.4):
|
||||
- Capacitor
|
||||
- CodetrixStudioCapacitorGoogleAuth (0.0.1):
|
||||
- Capacitor
|
||||
- GoogleSignIn (~> 6.2.4)
|
||||
- CordovaPluginsStatic (5.0.5):
|
||||
- CapacitorCordova
|
||||
- OneSignalXCFramework (= 5.0.0-beta-04)
|
||||
@@ -31,6 +40,14 @@ PODS:
|
||||
- FBSDKCoreKit_Basics (16.1.3)
|
||||
- FBSDKLoginKit (16.1.3):
|
||||
- FBSDKCoreKit (= 16.1.3)
|
||||
- GoogleSignIn (6.2.4):
|
||||
- AppAuth (~> 1.5)
|
||||
- GTMAppAuth (~> 1.3)
|
||||
- GTMSessionFetcher/Core (< 3.0, >= 1.1)
|
||||
- GTMAppAuth (1.3.1):
|
||||
- AppAuth/Core (~> 1.6)
|
||||
- GTMSessionFetcher/Core (< 3.0, >= 1.5)
|
||||
- GTMSessionFetcher/Core (2.3.0)
|
||||
- OneSignalXCFramework (5.0.0-beta-04):
|
||||
- OneSignalXCFramework/OneSignalCore (= 5.0.0-beta-04)
|
||||
- OneSignalXCFramework/OneSignalExtension (= 5.0.0-beta-04)
|
||||
@@ -67,6 +84,7 @@ DEPENDENCIES:
|
||||
- "CapacitorKeyboard (from `../../node_modules/@capacitor/keyboard`)"
|
||||
- "CapacitorPreferences (from `../../node_modules/@capacitor/preferences`)"
|
||||
- "CapacitorStatusBar (from `../../node_modules/@capacitor/status-bar`)"
|
||||
- "CodetrixStudioCapacitorGoogleAuth (from `../../node_modules/@codetrix-studio/capacitor-google-auth`)"
|
||||
- CordovaPluginsStatic (from `../capacitor-cordova-ios-plugins`)
|
||||
- FBSDKCoreKit (= 16.1.3)
|
||||
- FBSDKLoginKit (= 16.1.3)
|
||||
@@ -74,10 +92,14 @@ DEPENDENCIES:
|
||||
|
||||
SPEC REPOS:
|
||||
trunk:
|
||||
- AppAuth
|
||||
- FBAEMKit
|
||||
- FBSDKCoreKit
|
||||
- FBSDKCoreKit_Basics
|
||||
- FBSDKLoginKit
|
||||
- GoogleSignIn
|
||||
- GTMAppAuth
|
||||
- GTMSessionFetcher
|
||||
- OneSignalXCFramework
|
||||
|
||||
EXTERNAL SOURCES:
|
||||
@@ -101,10 +123,13 @@ EXTERNAL SOURCES:
|
||||
:path: "../../node_modules/@capacitor/preferences"
|
||||
CapacitorStatusBar:
|
||||
:path: "../../node_modules/@capacitor/status-bar"
|
||||
CodetrixStudioCapacitorGoogleAuth:
|
||||
:path: "../../node_modules/@codetrix-studio/capacitor-google-auth"
|
||||
CordovaPluginsStatic:
|
||||
:path: "../capacitor-cordova-ios-plugins"
|
||||
|
||||
SPEC CHECKSUMS:
|
||||
AppAuth: 3bb1d1cd9340bd09f5ed189fb00b1cc28e1e8570
|
||||
Capacitor: b1248915663add1bd6567e2b67c1c1fa3abcf5e8
|
||||
CapacitorApp: 7a5dec8b33573707164b293475d5c89ba684364a
|
||||
CapacitorCommunityAppleSignIn: eafdd59b18b38161fa5cceee7b0e31312b122958
|
||||
@@ -115,13 +140,17 @@ SPEC CHECKSUMS:
|
||||
CapacitorKeyboard: d1b25fde6f19744ad09c890862aefc6e2a7ded3d
|
||||
CapacitorPreferences: f03954bcb0ff09c792909e46bff88e3183c16b10
|
||||
CapacitorStatusBar: 190e0321b8734f4244d0c81baa183a00d5806ddf
|
||||
CodetrixStudioCapacitorGoogleAuth: fcce058390347c1ce5d8ac4764bdf1f5c1ee233b
|
||||
CordovaPluginsStatic: c1b87170d7e6c70c473250768081e07414af3879
|
||||
FBAEMKit: af2972f39bb0f3f7c45998f435b007833c32ffb2
|
||||
FBSDKCoreKit: 19e2e18b3be578d7a51fed8fdd8c152bef0b9511
|
||||
FBSDKCoreKit_Basics: dd9826ce3c9fd9f8cdf8dbbd0ef0a53e6c0c9e7e
|
||||
FBSDKLoginKit: c395c63a1a6cf4a8a1e6103fd94b8c46329ee81c
|
||||
GoogleSignIn: 5651ce3a61e56ca864160e79b484cd9ed3f49b7a
|
||||
GTMAppAuth: 0ff230db599948a9ad7470ca667337803b3fc4dd
|
||||
GTMSessionFetcher: 3a63d75eecd6aa32c2fc79f578064e1214dfdec2
|
||||
OneSignalXCFramework: 0225dc78b9c611be84733e5adc9b68638632c1e8
|
||||
|
||||
PODFILE CHECKSUM: 7d6a1b0dbd7cb987c2121b75ec46088af01da740
|
||||
PODFILE CHECKSUM: 6f3fca74c9da63a49dc76a4a79d1ca8197e91f23
|
||||
|
||||
COCOAPODS: 1.12.1
|
||||
COCOAPODS: 1.13.0
|
||||
|
||||
Generated
+17
-2
@@ -1,12 +1,12 @@
|
||||
{
|
||||
"name": "WrenchBoard",
|
||||
"version": "42.4.2",
|
||||
"version": "42.8.7",
|
||||
"lockfileVersion": 2,
|
||||
"requires": true,
|
||||
"packages": {
|
||||
"": {
|
||||
"name": "WrenchBoard",
|
||||
"version": "42.4.2",
|
||||
"version": "42.8.7",
|
||||
"dependencies": {
|
||||
"@angular/common": "^14.0.0",
|
||||
"@angular/core": "^14.0.0",
|
||||
@@ -25,6 +25,7 @@
|
||||
"@capacitor/keyboard": "^5.0.0",
|
||||
"@capacitor/preferences": "^5.0.6",
|
||||
"@capacitor/status-bar": "^5.0.0",
|
||||
"@codetrix-studio/capacitor-google-auth": "^3.3.2",
|
||||
"@ionic/angular": "^6.1.9",
|
||||
"angularx-qrcode": "^14.0.0",
|
||||
"bn-ng-idle": "^2.0.5",
|
||||
@@ -2629,6 +2630,14 @@
|
||||
"@capacitor/core": "^5.0.0"
|
||||
}
|
||||
},
|
||||
"node_modules/@codetrix-studio/capacitor-google-auth": {
|
||||
"version": "3.3.2",
|
||||
"resolved": "https://registry.npmjs.org/@codetrix-studio/capacitor-google-auth/-/capacitor-google-auth-3.3.2.tgz",
|
||||
"integrity": "sha512-RHYsgm/pU4JNmed5lYlT+xtoU6ktfw4/xG3o1iI5n7dhWO77kptOr2ZaVSXsYeOu1J93VeyOAyyqdaF+qkzxhw==",
|
||||
"peerDependencies": {
|
||||
"@capacitor/core": "^5.0.0"
|
||||
}
|
||||
},
|
||||
"node_modules/@colors/colors": {
|
||||
"version": "1.5.0",
|
||||
"resolved": "https://registry.npmjs.org/@colors/colors/-/colors-1.5.0.tgz",
|
||||
@@ -21661,6 +21670,12 @@
|
||||
"integrity": "sha512-6gvkUTotpzHlfn5KoIglbIqdaEWV/crLtCYXebtFtRAPofCU8EWcljGeeISKBYPE99xqsk3M66vRUY4OzsAYyA==",
|
||||
"requires": {}
|
||||
},
|
||||
"@codetrix-studio/capacitor-google-auth": {
|
||||
"version": "3.3.2",
|
||||
"resolved": "https://registry.npmjs.org/@codetrix-studio/capacitor-google-auth/-/capacitor-google-auth-3.3.2.tgz",
|
||||
"integrity": "sha512-RHYsgm/pU4JNmed5lYlT+xtoU6ktfw4/xG3o1iI5n7dhWO77kptOr2ZaVSXsYeOu1J93VeyOAyyqdaF+qkzxhw==",
|
||||
"requires": {}
|
||||
},
|
||||
"@colors/colors": {
|
||||
"version": "1.5.0",
|
||||
"resolved": "https://registry.npmjs.org/@colors/colors/-/colors-1.5.0.tgz",
|
||||
|
||||
@@ -30,6 +30,7 @@
|
||||
"@capacitor/keyboard": "^5.0.0",
|
||||
"@capacitor/preferences": "^5.0.6",
|
||||
"@capacitor/status-bar": "^5.0.0",
|
||||
"@codetrix-studio/capacitor-google-auth": "^3.3.2",
|
||||
"@ionic/angular": "^6.1.9",
|
||||
"angularx-qrcode": "^14.0.0",
|
||||
"bn-ng-idle": "^2.0.5",
|
||||
|
||||
@@ -2,6 +2,8 @@ import { Component } from '@angular/core';
|
||||
import { BnNgIdleService } from 'bn-ng-idle';
|
||||
import {SessionDataProviderService} from "./store/session-data-provider.service";
|
||||
import {Router} from "@angular/router"; // import it to your component
|
||||
import { Platform } from '@ionic/angular';
|
||||
import { GoogleAuth } from '@codetrix-studio/capacitor-google-auth';
|
||||
|
||||
@Component({
|
||||
selector: 'app-root',
|
||||
@@ -9,7 +11,11 @@ import {Router} from "@angular/router"; // import it to your component
|
||||
styleUrls: ['app.component.scss'],
|
||||
})
|
||||
export class AppComponent {
|
||||
constructor(private bnIdle: BnNgIdleService,private sessionDataProviderService : SessionDataProviderService, public router: Router) {
|
||||
constructor(
|
||||
private bnIdle: BnNgIdleService,
|
||||
private sessionDataProviderService : SessionDataProviderService,
|
||||
public router: Router,
|
||||
public platform: Platform) {
|
||||
// this.OneSignalInit();
|
||||
this.bnIdle.startWatching(2500).subscribe((res) => {
|
||||
if(res) {
|
||||
@@ -18,11 +24,18 @@ export class AppComponent {
|
||||
this.sessionDataProviderService.DestroySessionOnLogout();
|
||||
this.router.navigate(['login']);
|
||||
}
|
||||
})
|
||||
});
|
||||
this.initializeApp();
|
||||
}
|
||||
|
||||
// Call this function when your app starts
|
||||
OneSignalInit(): void {
|
||||
console.log('Moved to home');
|
||||
}
|
||||
|
||||
initializeApp(): void {
|
||||
this.platform.ready().then(() => {
|
||||
//GoogleAuth.initialize()
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
@@ -72,12 +72,12 @@
|
||||
</ion-buttons>
|
||||
|
||||
<ion-buttons>
|
||||
<ion-button>
|
||||
<ion-button (click) ="onLoginGoogle()" >
|
||||
<ion-icon name="logo-google"></ion-icon>
|
||||
</ion-button>
|
||||
</ion-buttons>
|
||||
|
||||
<ion-buttons>
|
||||
<ion-buttons *ngIf="ios">
|
||||
<ion-button (click) ="onLoginApple()" >
|
||||
<ion-icon name="logo-apple"></ion-icon>
|
||||
</ion-button>
|
||||
|
||||
@@ -4,7 +4,7 @@ import { WrenchService } from 'src/app/services/wrench.service';
|
||||
import { SessionDataProviderService } from 'src/app/store/session-data-provider.service';
|
||||
import { BlogDataService } from 'src/app/store/blog-data.service';
|
||||
import { environment} from "../../../environments/environment";
|
||||
import { AlertController } from '@ionic/angular';
|
||||
import { AlertController, Platform } from '@ionic/angular';
|
||||
import { Preferences } from '@capacitor/preferences';
|
||||
import { Capacitor } from '@capacitor/core';
|
||||
import jwt_decode from "jwt-decode";
|
||||
@@ -17,6 +17,7 @@ import {
|
||||
FacebookLogin,
|
||||
FacebookLoginResponse,
|
||||
} from '@capacitor-community/facebook-login';
|
||||
import { GoogleAuth, User } from '@codetrix-studio/capacitor-google-auth';
|
||||
|
||||
@Component({
|
||||
selector: 'app-login',
|
||||
@@ -32,15 +33,30 @@ export class LoginPage implements OnInit {
|
||||
appleSignInAbortController: any;
|
||||
appleSignInWindow: any;
|
||||
state: any;
|
||||
ios: boolean;
|
||||
android: boolean;
|
||||
|
||||
constructor(
|
||||
private router: Router,
|
||||
private wrenchService: WrenchService,
|
||||
public sessionDataProviderService:SessionDataProviderService,
|
||||
public blogDataService:BlogDataService,
|
||||
private alertController: AlertController
|
||||
private alertController: AlertController,
|
||||
public platform: Platform
|
||||
) {
|
||||
|
||||
// https://ionicframework.com/docs/angular/platform
|
||||
this.ios = platform.is('ios');
|
||||
this.android = platform.is('android');
|
||||
}
|
||||
|
||||
ionViewDidEnter() {
|
||||
// GoogleAuth.init();
|
||||
// use hook after platform dom ready
|
||||
GoogleAuth.initialize({
|
||||
clientId: '817021856543-ad9nsjgdpsu2s2jrl63j3ihrv7lbf6ma.apps.googleusercontent.com',
|
||||
scopes: ['profile', 'email'],
|
||||
grantOfflineAccess: true,
|
||||
});
|
||||
}
|
||||
|
||||
ngOnInit() {
|
||||
@@ -115,6 +131,54 @@ getBlogData(){
|
||||
this.router.navigate(['startscan']);
|
||||
}
|
||||
|
||||
onLoginGoogle() {
|
||||
GoogleAuth.signIn().then((user: User) => {
|
||||
//const credential = auth.GoogleAuthProvider.credential(user.authentication.idToken);
|
||||
//return this.afAuth.auth.signInAndRetrieveDataWithCredential(credential);
|
||||
|
||||
if (user) {
|
||||
const oauth2Data = {
|
||||
"auth_type": "GOOGLE",
|
||||
"access_token": user.authentication.accessToken,
|
||||
"refresh_token": user.authentication.refreshToken,
|
||||
"idToken": user.authentication.idToken,
|
||||
"auth_code": user.serverAuthCode,
|
||||
"user": user
|
||||
};
|
||||
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(user);
|
||||
this.showAlert("Error", "Login failed!");
|
||||
}
|
||||
}).catch((error: any) => {
|
||||
this.showAlert("Error", error);
|
||||
console.log(error);
|
||||
});
|
||||
}
|
||||
|
||||
onLoginFacebook() {
|
||||
const FACEBOOK_PERMISSIONS = [
|
||||
'email',
|
||||
|
||||
Reference in New Issue
Block a user