Exemple #1
0
        public AuthResponse Authenticate(AuthRequest request)
        {
            new Assertor(mess => new NotValidRequestException(mess))
            .Add(() => !string.IsNullOrEmpty(request.Id), "Id of user can't be empty")     // TODO change on codes for decision making on front-end part
            .Add(() => !string.IsNullOrEmpty(request.Secret), "Secret can't be empty")
            .Assert();

            var user = mRepositoriesManager.UsersRepository.GetUserByLogin(request.Id);

            if (user == null)
            {
                return(AuthResponse.Fail());
            }

            var authdata = mRepositoriesManager.UsersRepository.GetAuthenticationData(user.Id.Value, UsersApi.LoginTypes.LoginPassword);

            return(authdata != null && authdata.Secret == request.Secret
                ? AuthResponse.Success("/pages/index.html")
                : AuthResponse.Fail());
        }
 public static int?AuthTimeDistanceRecommended(AuthResponse authResponse)
 {
     return((authResponse == null) ? null : new int?((!authResponse.Success()) ? 60000 : 0));
 }