public static void SignOut() { var objIdentity = DinazorIdentity.UnauthenticatedIdentity(); _objPrincipal = new DinazorPrincipal(objIdentity); User = _objPrincipal; }
private static DinazorIdentity AuthenticateandAuthorizeMe(string mail, string password) { _dinazorIdentity = new DinazorIdentity(); try { var userManager = new UserManager(); var tokenData = userManager.Login(mail, password); if (tokenData.IsSuccess) { return(AuthenticateMe(tokenData.Data)); } if (_dinazorIdentity.TokenUser == null) { _dinazorIdentity.TokenUser = new TokenUser(); } _dinazorIdentity.TokenUser.Token = string.Empty; _dinazorIdentity.TokenUser.Mail = string.Empty; _dinazorIdentity.TokenUser.IsAuthenticated = false; return(_dinazorIdentity); } catch (Exception exce) { throw new Exception("Error while retrieving the authorization details. Please contact administrator.", exce); } }
private static DinazorIdentity AuthenticateMe(TokenUser tokenUser) { _dinazorIdentity = new DinazorIdentity(); _dinazorIdentity.TokenUser = new TokenUser(); try { if (tokenUser != null) { _dinazorIdentity.TokenUser = tokenUser; _dinazorIdentity.IsAuthenticated = true; } else { _dinazorIdentity.TokenUser.Token = string.Empty; _dinazorIdentity.TokenUser.Mail = string.Empty; _dinazorIdentity.TokenUser.IsAuthenticated = false; } return(_dinazorIdentity); } catch (Exception exce) { throw new Exception("Error while retrieving the authorization details. Please contact administrator.", exce); } }
public static bool AuthenticateUser(string token) { var objIdentity = DinazorIdentity.GetIdentity(token); if (!objIdentity.IsAuthenticated) { return(objIdentity.IsAuthenticated); } _objPrincipal = new DinazorPrincipal(objIdentity); User = _objPrincipal; return(objIdentity.IsAuthenticated); }
private static DinazorIdentity AuthenticateMe(string token) { _dinazorIdentity = new DinazorIdentity(); try { var jwtManager = new JwtManager(); var tokenUserResult = jwtManager.Decode(token); if (tokenUserResult.IsSuccess) { return(AuthenticateMe(tokenUserResult.Data)); } TokenUser tokenUser = null; return(AuthenticateMe(tokenUser)); } catch (Exception ex) { throw new Exception("Error while retrieving the authorization details. Please contact administrator.", ex); } }