Ejemplo n.º 1
0
        public LoginResult Logon(LogonArg arg)
        {
            var user = GetUserByLoginAndPassword(arg);
            if (user == null)
                return new LoginResult { ErrorMessage = Messages.WrongLoginOrPassword };
            if (!user.IsActive)
                return new LoginResult { ErrorMessage = Messages.UserEmailUnapproved };

            var authInfo = new AuthInfo { UserId = user.UserId };

            var token = AuthTokens.Instance.AddAuth(authInfo);

            return arg.DefaultInstanceId != 0
                        ? LogonToInstance(token, arg.DefaultInstanceId)
                        : LogonUserWithoutInstance(token, user.UserId);
        }
Ejemplo n.º 2
0
 private User GetUserByLoginAndPassword(LogonArg arg)
 {
     switch (AppConfiguration.AuthenticationMethod)
     {
         case AuthenticationType.Native:
             return Db.GetAndAuthenticateUser(arg);
         case AuthenticationType.ActiveDirectory:
             var adHelper = new AdHelper(AppConfiguration.LDAPServer);
             BaseResult adResult = adHelper.Authenticate(arg.Login, arg.PasswordHash);
             if (adResult.IsError()) return null;
             return Db.GetUserByLogin(arg.Login);
     }
     return null;
 }
 public LoginResult Logon(LogonArg arg)
 {
     return SendPostRequest<LoginResult, LogonArg>("logon", arg);
 }