public BaseResponse <AuthenticationResponse> Login(AuthenticationRequest request) { AuthenticationResponse response = new AuthenticationResponse(); if (request.Password == null || request.UserName == null) { throw new Exception("Username or Password Can Not Be Null"); } if (request.UserName == "admin" && request.Password == "123") { new SessionBL().SetCurrentPrincipal(new UserInfo() { UserName = request.UserName, Password = request.Password, BirthDate = DateTime.Now, Email = "*****@*****.**", ID = 1, Name = "Emirhan", Surname = "Aksoy", PhoneNumber = "0000000000" }); response.Token = JWTBusiness.GenerateToken(request.UserName); return(new BaseResponse <AuthenticationResponse>(response)); } else { return(new BaseResponse <AuthenticationResponse>(null, false, "Login Failed")); } }
public void ValidateToken(string token) { //DataBase Token kontrol tablosuna istek atıp username i alıcaz string username = "******"; var tokenUsername = JWTBusiness.ValidateToken(token); if (username != tokenUsername) { throw new Exception("Not Authorized For This Request."); } }