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.Username = 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 AuthenticateandAuthorizeMe(string userName, string password) { _dinazorIdentity = new DinazorIdentity(); try { var tokenManager = IocManager.Instance.Resolve <ITokenManager>(); var tokenData = tokenManager.Login(new BaseTokenUser() { Username = userName, Password = password }); if (tokenData.Result.IsSuccess) { return(AuthenticateMe(tokenData.Result.Data)); } if (_dinazorIdentity.TokenUser == null) { _dinazorIdentity.TokenUser = new TokenUser(); } _dinazorIdentity.TokenUser.Token = string.Empty; _dinazorIdentity.TokenUser.Username = 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 void SignOut() { var objIdentity = DinazorIdentity.UnauthenticatedIdentity(); _objPrincipal = new DinazorPrincipal(objIdentity); User = _objPrincipal; }
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 tokenData = IocManager.Instance.Resolve <ITokenManager>().GetUserByToken(token); return(AuthenticateMe(tokenData.Data)); } catch (Exception ex) { throw new Exception("Error while retrieving the authorization details. Please contact administrator.", ex); } }