This commit is contained in:
tiago.kayaya
2021-02-24 16:39:11 +01:00
parent fe2f3bccad
commit 5b0e22e427
6 changed files with 98 additions and 41 deletions
+2 -1
View File
@@ -5,6 +5,8 @@
<author email="info@equilibrium.co.ao" href="http://www.equilibrium.co.ao/">Equilibrium Team</author> <author email="info@equilibrium.co.ao" href="http://www.equilibrium.co.ao/">Equilibrium Team</author>
<content src="index.html" /> <content src="index.html" />
<access origin="*" /> <access origin="*" />
<allow-navigation href="http://*/*" />
<allow-navigation href="https://*/*" />
<allow-intent href="http://*/*" /> <allow-intent href="http://*/*" />
<allow-intent href="https://*/*" /> <allow-intent href="https://*/*" />
<allow-intent href="tel:*" /> <allow-intent href="tel:*" />
@@ -100,7 +102,6 @@
<splash height="1792" src="resources/ios/splash/Default-1792h~iphone.png" width="828" /> <splash height="1792" src="resources/ios/splash/Default-1792h~iphone.png" width="828" />
<splash height="828" src="resources/ios/splash/Default-Landscape-1792h~iphone.png" width="1792" /> <splash height="828" src="resources/ios/splash/Default-Landscape-1792h~iphone.png" width="1792" />
</platform> </platform>
<plugin name="cordova-plugin-whitelist" spec="1.3.3" />
<plugin name="cordova-plugin-statusbar" spec="2.4.2" /> <plugin name="cordova-plugin-statusbar" spec="2.4.2" />
<plugin name="cordova-plugin-device" spec="2.0.2" /> <plugin name="cordova-plugin-device" spec="2.0.2" />
<plugin name="cordova-plugin-splashscreen" spec="5.0.2" /> <plugin name="cordova-plugin-splashscreen" spec="5.0.2" />
+8 -18
View File
@@ -1815,6 +1815,14 @@
"@types/cordova": "^0.0.34" "@types/cordova": "^0.0.34"
} }
}, },
"@ionic-native/http": {
"version": "5.31.1",
"resolved": "https://registry.npmjs.org/@ionic-native/http/-/http-5.31.1.tgz",
"integrity": "sha512-J9pLHycF6ndpqIYsyZEVjEnz33jbTWnE5vbq+Lpytd6KO/jE/Lyuy8z0wTzVkKYI1bKpgC+Q0XuBt2UgyEuPdA==",
"requires": {
"@types/cordova": "^0.0.34"
}
},
"@ionic-native/in-app-browser": { "@ionic-native/in-app-browser": {
"version": "5.31.1", "version": "5.31.1",
"resolved": "https://registry.npmjs.org/@ionic-native/in-app-browser/-/in-app-browser-5.31.1.tgz", "resolved": "https://registry.npmjs.org/@ionic-native/in-app-browser/-/in-app-browser-5.31.1.tgz",
@@ -5365,11 +5373,6 @@
"integrity": "sha512-Jb3V72btxf3XHpkPQsGdyc8N6tVBYn1vsxSFj43fIz9vonJDUThYPCJJHqk6PX6N4dJw6I4FjxkpfCR4LDYMlw==", "integrity": "sha512-Jb3V72btxf3XHpkPQsGdyc8N6tVBYn1vsxSFj43fIz9vonJDUThYPCJJHqk6PX6N4dJw6I4FjxkpfCR4LDYMlw==",
"dev": true "dev": true
}, },
"cordova-plugin-file": {
"version": "6.0.2",
"resolved": "https://registry.npmjs.org/cordova-plugin-file/-/cordova-plugin-file-6.0.2.tgz",
"integrity": "sha512-m7cughw327CjONN/qjzsTpSesLaeybksQh420/gRuSXJX5Zt9NfgsSbqqKDon6jnQ9Mm7h7imgyO2uJ34XMBtA=="
},
"cordova-plugin-filepath": { "cordova-plugin-filepath": {
"version": "1.5.8", "version": "1.5.8",
"resolved": "https://registry.npmjs.org/cordova-plugin-filepath/-/cordova-plugin-filepath-1.5.8.tgz", "resolved": "https://registry.npmjs.org/cordova-plugin-filepath/-/cordova-plugin-filepath-1.5.8.tgz",
@@ -5469,19 +5472,6 @@
"which": "^1.3.0" "which": "^1.3.0"
} }
}, },
"cordova-sqlite-storage": {
"version": "5.1.0",
"resolved": "https://registry.npmjs.org/cordova-sqlite-storage/-/cordova-sqlite-storage-5.1.0.tgz",
"integrity": "sha512-UmHe9yQiYblDBToh3z91WHuD6ZgmCm3VX+1QFseYQs4WVQ3+ndj22qyGby/NV0uyCgok91gB1obLjLM+9vYJEw==",
"requires": {
"cordova-sqlite-storage-dependencies": "3.0.0"
}
},
"cordova-sqlite-storage-dependencies": {
"version": "3.0.0",
"resolved": "https://registry.npmjs.org/cordova-sqlite-storage-dependencies/-/cordova-sqlite-storage-dependencies-3.0.0.tgz",
"integrity": "sha512-A7gV5lQZc0oPrJ/a+lsZmMZr7vYou4MXyQFOY+b/dwuCMsagLT0EsL7oY54tqzpvjtzLfh0aZGGm9i8DMAIFSA=="
},
"core-js": { "core-js": {
"version": "3.9.0", "version": "3.9.0",
"resolved": "https://registry.npmjs.org/core-js/-/core-js-3.9.0.tgz", "resolved": "https://registry.npmjs.org/core-js/-/core-js-3.9.0.tgz",
+6 -7
View File
@@ -30,6 +30,7 @@
"@ionic-native/core": "^5.0.7", "@ionic-native/core": "^5.0.7",
"@ionic-native/file": "^5.30.0", "@ionic-native/file": "^5.30.0",
"@ionic-native/file-path": "^5.30.0", "@ionic-native/file-path": "^5.30.0",
"@ionic-native/http": "^5.31.1",
"@ionic-native/in-app-browser": "^5.28.0", "@ionic-native/in-app-browser": "^5.28.0",
"@ionic-native/ionic-webview": "^5.30.0", "@ionic-native/ionic-webview": "^5.30.0",
"@ionic-native/status-bar": "^5.0.0", "@ionic-native/status-bar": "^5.0.0",
@@ -41,10 +42,8 @@
"angular-calendar": "^0.28.22", "angular-calendar": "^0.28.22",
"angular-tag-cloud-module": "^5.2.2", "angular-tag-cloud-module": "^5.2.2",
"cordova-plugin-camera": "^5.0.1", "cordova-plugin-camera": "^5.0.1",
"cordova-plugin-file": "^6.0.2",
"cordova-plugin-filepath": "^1.5.8", "cordova-plugin-filepath": "^1.5.8",
"cordova-res": "^0.15.1", "cordova-res": "^0.15.1",
"cordova-sqlite-storage": "^5.1.0",
"date-fns": "^2.16.1", "date-fns": "^2.16.1",
"ionic-selectable": "^4.5.0", "ionic-selectable": "^4.5.0",
"ionic2-alpha-scroll": "^2.0.1", "ionic2-alpha-scroll": "^2.0.1",
@@ -80,7 +79,7 @@
"cordova-plugin-ionic-webview": "^4.2.1", "cordova-plugin-ionic-webview": "^4.2.1",
"cordova-plugin-splashscreen": "^5.0.2", "cordova-plugin-splashscreen": "^5.0.2",
"cordova-plugin-statusbar": "^2.4.2", "cordova-plugin-statusbar": "^2.4.2",
"cordova-plugin-whitelist": "^1.3.3", "cordova-plugin-whitelist": "^1.3.4",
"jasmine-core": "~3.6.0", "jasmine-core": "~3.6.0",
"jasmine-spec-reporter": "~5.0.0", "jasmine-spec-reporter": "~5.0.0",
"karma": "~5.0.0", "karma": "~5.0.0",
@@ -96,7 +95,6 @@
"description": "An Ionic project", "description": "An Ionic project",
"cordova": { "cordova": {
"plugins": { "plugins": {
"cordova-plugin-whitelist": {},
"cordova-plugin-statusbar": {}, "cordova-plugin-statusbar": {},
"cordova-plugin-device": {}, "cordova-plugin-device": {},
"cordova-plugin-splashscreen": {}, "cordova-plugin-splashscreen": {},
@@ -106,8 +104,9 @@
"cordova-plugin-ionic-keyboard": {}, "cordova-plugin-ionic-keyboard": {},
"cordova-plugin-inappbrowser": {}, "cordova-plugin-inappbrowser": {},
"cordova-plugin-camera": {}, "cordova-plugin-camera": {},
"cordova-sqlite-storage": {}, "cordova-plugin-compat": {},
"cordova-plugin-compat": {} "cordova-plugin-whitelist": {},
"cordova-sqlite-storage": {}
}, },
"platforms": [ "platforms": [
"browser", "browser",
@@ -120,4 +119,4 @@
"url": "git+https://Kayaya@bitbucket.org/equilibriumito/gabinete-digital.git" "url": "git+https://Kayaya@bitbucket.org/equilibriumito/gabinete-digital.git"
}, },
"license": "ISC" "license": "ISC"
} }
+4 -1
View File
@@ -11,6 +11,7 @@ import { PhotoService } from 'src/app/services/photo.service';
import { NotificationsService } from 'src/app/services/notifications.service'; import { NotificationsService } from 'src/app/services/notifications.service';
import { HttpClient, HttpHeaders, HttpParams } from '@angular/common/http'; import { HttpClient, HttpHeaders, HttpParams } from '@angular/common/http';
import { Token } from '../../models/token.model'; import { Token } from '../../models/token.model';
import { AlertService } from 'src/app/services/alert.service';
/* import { Plugins, PushNotification, PushNotificationToken, PushNotificationActionPerformed } from '@capacitor/core'; /* import { Plugins, PushNotification, PushNotificationToken, PushNotificationActionPerformed } from '@capacitor/core';
@@ -38,7 +39,8 @@ export class LoginPage implements OnInit {
private storageService: StorageService, private storageService: StorageService,
private toastService: ToastService, private toastService: ToastService,
private photoService: PhotoService, private photoService: PhotoService,
public alertController: AlertController) { } public alertController: AlertController,
private alertService: AlertService,) { }
ngOnInit() { ngOnInit() {
@@ -124,6 +126,7 @@ export class LoginPage implements OnInit {
BasicAuthKey: "" BasicAuthKey: ""
} }
if (await this.authService.login(this.userattempt)) { if (await this.authService.login(this.userattempt)) {
this.alertService.presentAlert('5');
this.loginRocketChat(); this.loginRocketChat();
//this.storeUserIdANdToken(); //this.storeUserIdANdToken();
+72 -11
View File
@@ -1,5 +1,5 @@
import { Injectable } from '@angular/core'; import { Injectable } from '@angular/core';
import { StorageService } from './storage.service'; /* import { StorageService } from './storage.service'; */
import { Router } from '@angular/router'; import { Router } from '@angular/router';
import { HttpClient, HttpHeaders, HttpParams } from '@angular/common/http'; import { HttpClient, HttpHeaders, HttpParams } from '@angular/common/http';
import { User } from '../models/user.model'; import { User } from '../models/user.model';
@@ -7,6 +7,9 @@ import { environment } from 'src/environments/environment';
import { HttpService } from './http.service'; import { HttpService } from './http.service';
import { BehaviorSubject, Observable } from 'rxjs'; import { BehaviorSubject, Observable } from 'rxjs';
import { AuthConnstants } from '../config/auth-constants'; import { AuthConnstants } from '../config/auth-constants';
import { AlertService } from './alert.service';
import { map } from 'rxjs/operators';
import { Storage } from '@ionic/storage';
@Injectable({ @Injectable({
providedIn: 'root' providedIn: 'root'
@@ -16,18 +19,23 @@ export class AuthService {
userId$ = new BehaviorSubject<any>(''); userId$ = new BehaviorSubject<any>('');
headers: HttpHeaders; headers: HttpHeaders;
opts:any; opts:any;
rs:any;
constructor( constructor(
private http: HttpClient, private http: HttpClient,
private httpService: HttpService, private httpService: HttpService,
private storageService:StorageService, /* private storageService:StorageService, */
private router:Router private router:Router,
private alertCrontroller: AlertService,
private storage: Storage,
) { ) {
this.headers = new HttpHeaders(); this.headers = new HttpHeaders();
} }
public ValidatedUser:User; public ValidatedUser:User;
public ValidatedUser2:any;
async login(user: User): Promise<boolean> { async login(user: User): Promise<boolean> {
this.alertCrontroller.presentAlert('1');
user.BasicAuthKey = 'Basic ' + btoa(user.username + '@' + user.domainName + ':' + user.password); //conversão em base64 das credenciais inseridas user.BasicAuthKey = 'Basic ' + btoa(user.username + '@' + user.domainName + ':' + user.password); //conversão em base64 das credenciais inseridas
const options = { headers: {'Authorization': user.BasicAuthKey }}; const options = { headers: {'Authorization': user.BasicAuthKey }};
@@ -40,23 +48,76 @@ export class AuthService {
let result: boolean | PromiseLike<boolean>; let result: boolean | PromiseLike<boolean>;
let response: any; let response: any;
result = await this.http.get<boolean>(service, options).toPromise(); this.alertCrontroller.presentAlert('2');
this.http.get('http://jsonplaceholder.typicode.com/todos/1');
this.alertCrontroller.presentAlert('2.1');
this.http.get('https://jsonplaceholder.typicode.com/todos/1');
this.alertCrontroller.presentAlert('2.2');
var that = this;
await this.http.get<boolean>(service, options).subscribe(res=>{
this.alertCrontroller.presentAlert('3.1');
result = res;
this.storage.set('login', res);
return result;
if (result)
{
this.alertCrontroller.presentAlert('4');
this.ValidatedUser = user;
//this.storageService.store(AuthConnstants.USER, response);
}
});
this.storage.get('name').then((val) => {
console.log('Your age is', val);
});
this.alertCrontroller.presentAlert('3');
response = await this.http.post<any>(environment.apiURL + "UserAuthentication/Login", '', this.opts).toPromise(); response = await this.http.post<any>(environment.apiURL + "UserAuthentication/Login", '', this.opts).toPromise();
console.log(response);
/* this.http.post(environment.apiURL + "UserAuthentication/Login", '', this.opts).subscribe(res=>{ /* this.http.post(environment.apiURL + "UserAuthentication/Login", '', this.opts).subscribe(res=>{
this.storageService.store(AuthConnstants.USER, res); this.storageService.store(AuthConnstants.USER, res);
this.ValidatedUser = user; this.ValidatedUser = user;
response = user; response = user;
console.log(user); console.log(user);
}); */ }); */
if (result) /* this.rs = this.storage.get('name').toPromise()
{ .then((val) => {
this.ValidatedUser = user; return val;
//this.storageService.store(AuthConnstants.USER, response); }); */
}
return result; let t = this.get('name');
console.log(this.ValidatedUser2);
console.log(this.rs.map(responce=>responce.json()).toPromise());
return false;
} }
async get(key: string): Promise<any> {
try {
const result = await this.storage.get(key);
console.log('storageGET: ' + key + ': ' + result);
if (result != null) {
this.ValidatedUser2 = result;
return result;
}
return null;
} catch (reason) {
console.log(reason);
return null;
}
}
logout(){ logout(){
this.ValidatedUser = null; this.ValidatedUser = null;
} }
+6 -3
View File
@@ -11,15 +11,18 @@
<meta name="viewport" content="viewport-fit=cover, width=device-width, height=device-hight, initial-scale=1.0, minimum-scale=1.0, maximum-scale=1.0, user-scalable=no" /> <meta name="viewport" content="viewport-fit=cover, width=device-width, height=device-hight, initial-scale=1.0, minimum-scale=1.0, maximum-scale=1.0, user-scalable=no" />
<meta name="format-detection" content="telephone=no" /> <meta name="format-detection" content="telephone=no" />
<meta name="msapplication-tap-highlight" content="no" /> <meta name="msapplication-tap-highlight" content="no" />
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/5.14.0/css/all.min.css" integrity="sha512-1PKOgIY59xJ8Co8+NE6FZ+LOAZKjy+KY8iq0G4B3CyeY6wYHN3yt9PW0XpSriVlkMXe40PTKnXrLnZ9+fkDaog==" crossorigin="anonymous" /> <!-- <link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/5.14.0/css/all.min.css" integrity="sha512-1PKOgIY59xJ8Co8+NE6FZ+LOAZKjy+KY8iq0G4B3CyeY6wYHN3yt9PW0XpSriVlkMXe40PTKnXrLnZ9+fkDaog==" crossorigin="anonymous" /> -->
<!-- Added -->
<link href="https://fonts.googleapis.com/css2?family=Roboto:ital,wght@0,100;0,300;0,400;0,500;0,700;0,900;1,100;1,300;1,400;1,500;1,700;1,900&display=swap" rel="stylesheet"> <meta http-equiv="Content-Security-Policy" content="default-src *; style-src 'self' 'unsafe-inline'; script-src 'self' 'unsafe-inline' 'unsafe-eval' https://fonts.googleapis.com; font-src 'self' https://fonts.gstatic.com;"/>
<!-- <link href="https://fonts.googleapis.com/css2?family=Roboto:ital,wght@0,100;0,300;0,400;0,500;0,700;0,900;1,100;1,300;1,400;1,500;1,700;1,900&display=swap" rel="stylesheet"> -->
<link rel="icon" type="image/x-icon" href="assets/icon/favicon.png" /> <link rel="icon" type="image/x-icon" href="assets/icon/favicon.png" />
<!-- add to homescreen for ios --> <!-- add to homescreen for ios -->
<meta name="apple-mobile-web-app-capable" content="yes" /> <meta name="apple-mobile-web-app-capable" content="yes" />
<meta name="apple-mobile-web-app-status-bar-style" content="black" /> <meta name="apple-mobile-web-app-status-bar-style" content="black" />
</head> </head>
<body> <body>