private async void btnLogin_Click(object sender, EventArgs e) { try { APIService.Username = txtUsername.Text; APIService.Password = txtPassword.Text; KorisniciLoginRequest newLogin = new KorisniciLoginRequest { Password = txtPassword.Text, Username = txtUsername.Text }; var temp = await _service.Login <Model.Korisnici>(newLogin); APIService.Permisije = temp.UlogaId; APIService.KorisnikId = temp.KorisnikId; if (APIService.Permisije == 4) { MessageBox.Show("Pacijentima nije dozvoljeno se logovat na desktop aplikaciju!", "Autorizacija", MessageBoxButtons.OK, MessageBoxIcon.Warning); } else { //this.Hide(); frmIndex frm = new frmIndex(); frm.Show(); } } catch (Exception exception) { MessageBox.Show(exception.Message, "Authentikacija", MessageBoxButtons.OK, MessageBoxIcon.Error); } }
async Task Login() { if (string.IsNullOrWhiteSpace(Username)) { UsernameValidation = true; if (string.IsNullOrWhiteSpace(Password)) { PasswordValidation = true; } else { PasswordValidation = false; } } else if (string.IsNullOrWhiteSpace(Password)) { UsernameValidation = false; PasswordValidation = true; } else { UsernameValidation = false; PasswordValidation = false; IsBusy = true; APIService.Username = Username; APIService.Password = Password; KorisniciLoginRequest newLogin = new KorisniciLoginRequest { Password = APIService.Password, Username = APIService.Username }; try { var temp = await _service.Login <Model.Korisnici>(newLogin); APIService.KorisnikId = temp.KorisnikId; APIService.Permisije = temp.UlogaId; APIService.LogiraniKorisnik = temp; if (APIService.Permisije == 4) { var temp2 = await _serviceKorisnikPacijenti.GetById <Model.KorisnikPacijent>(temp.KorisnikId); APIService.PacijentId = temp2.PacijentId; Application.Current.MainPage = new MainPage(); } else { IsBusy = false; Username = string.Empty; Password = string.Empty; await Application.Current.MainPage.DisplayAlert("Greška", "Mobilna aplikacija je namjenjena samo za pacijente!", "OK"); } } catch (Exception) { IsBusy = false; Password = string.Empty; await Application.Current.MainPage.DisplayAlert("Greška", "Niste unijeli ispravne login podatke!", "OK"); } } }
public Model.Korisnici LoginMobile(KorisniciLoginRequest request) { var user = _context.Korisnici.FirstOrDefault(x => x.KorisnickoIme == request.Username); if (user != null) { var newHash = GenerateHash(user.LozinkaSalt, request.Password); if (newHash == user.LozinkaHash) { return(_mapper.Map <Model.Korisnici>(user)); } } return(null); }
public Model.Korisnici Authenticiraj(KorisniciLoginRequest request) { var user = _context.Korisnici.Include("KorisniciUloge.Uloga").FirstOrDefault(x => x.KorisnickoIme == request.Username); if (user != null) { var newHash = GenerateHash(user.LozinkaSalt, request.Password); if (newHash == user.LozinkaHash) { Model.Korisnici korisnici = _mapper.Map <Model.Korisnici>(user); return(korisnici); } } return(null); }
public Model.Korisnici Login(KorisniciLoginRequest request) { var entity = _context.Korisnici.Include("KorisniciUloge.Uloga").FirstOrDefault(x => x.KorisnickoIme == request.Username); if (entity == null) { throw new UserException("Pogrešan username ili password"); } var hash = GenerateHash(entity.LozinkaSalt, request.Password); if (hash != entity.LozinkaHash) { throw new UserException("Pogrešan username ili password"); } return(_mapper.Map <Model.Korisnici>(entity)); }
public Model.Korisnici Login(KorisniciLoginRequest request) { return(_service.Login(request)); }