public virtual async Task <AuthLoginResult> Login(string userName, string plainPassword) { //Dohvati korisnika iz baze User fetchedUser = await _repository.GetUserByNameAsync(userName); var result = new AuthLoginResult(); if (fetchedUser != null) //ako korisnik postoji { //provjeri password bool goodPassword = await _hasher.CheckPassword(fetchedUser.HashedPassword, plainPassword); if (!goodPassword) { result.SetErrorMessage("Wrong password :("); return(result); } //kreiraj jwt token (korisnik je uspjesno prijavljen) result.Token = _token.CreateJWTToken(fetchedUser); return(result); } //Vrati poruku da korisnik ne postoji result.SetErrorMessage("User doesnt exist"); return(result); }