Exemplo n.º 1
0
        private Exception createExceptionForFailedLoginAttempt(HozaruLoginResultType result, string usernameOrEmailAddress, string tenancyName)
        {
            switch (result)
            {
            case HozaruLoginResultType.Success:
                return(new ApplicationException("Don't call this method with a success result!"));

            case HozaruLoginResultType.InvalidUserNameOrEmailAddress:
            case HozaruLoginResultType.InvalidPassword:
                return(new HozaruException(IdentityMessages.InvalidUserNameOrPassword));

            case HozaruLoginResultType.InvalidTenancyName:
                return(new HozaruException(string.Format(IdentityMessages.ThereIsNoTenantDefinedWithName, tenancyName)));

            case HozaruLoginResultType.TenantIsNotActive:
                return(new HozaruException(string.Format(IdentityMessages.TenantIsNotActive, tenancyName)));

            case HozaruLoginResultType.UserIsNotActive:
                return(new HozaruException(string.Format(IdentityMessages.UserIsNotActiveAndCanNotLogin, usernameOrEmailAddress)));

            case HozaruLoginResultType.UserEmailIsNotConfirmed:
                return(new HozaruException("Your email address is not confirmed. You can not login")); //TODO: localize message

            default:                                                                                   //Can not fall to default actually. But other result types can be added in the future and we may forget to handle it
                //Logger.Warn("Unhandled login fail reason: " + result);
                return(new HozaruException(IdentityMessages.LoginFailed));
            }
        }
Exemplo n.º 2
0
 public HozaruLoginResult(HozaruLoginResultType result)
 {
     Result = result;
 }