This commit is contained in:
tiago.kayaya
2021-01-15 15:25:13 +01:00
parent 092557b21e
commit 7e18af8233
4 changed files with 10 additions and 33 deletions
+1 -29
View File
@@ -7,7 +7,6 @@ import { environment } from 'src/environments/environment';
import { HttpService } from './http.service';
import { BehaviorSubject, Observable } from 'rxjs';
import { AuthConnstants } from '../config/auth-constants';
import { AlertController } from '@ionic/angular';
@Injectable({
providedIn: 'root'
@@ -18,51 +17,24 @@ export class AuthService {
private http: HttpClient,
private httpService: HttpService,
private storageService:StorageService,
public alertController: AlertController,
private router:Router
) { }
public ValidatedUser:User;
async presentAlert(message:string) {
const alert = await this.alertController.create({
cssClass: 'my-custom-class',
header: 'Mensagem do sistema',
message: message,
buttons: ['OK']
});
await alert.present();
}
async login(user: User): Promise<boolean> {
user.BasicAuthKey = 'Basic ' + btoa(user.domainName + '\\' + user.username + ':' + user.password); //conversão em base64 das credenciais inseridas
const options = { headers: {'Authorization': user.BasicAuthKey }};
const service = environment.apiURL + "userauthentication/GetValidateAuth";
let result: boolean | PromiseLike<boolean>;
this.presentAlert(service);
try {
result = await this.http.get<boolean>(service, options).toPromise();
} catch (error) {
this.presentAlert('Erro '+error);
}
result = await this.http.get<boolean>(service, options).toPromise();
if (result)
{
this.presentAlert('7');
this.ValidatedUser = user;
this.presentAlert('8');
}
return result;