Exemple #1
0
        public ResponseDTO <bool> UserAcceptTOS(ParkingMasterFrontendDTO request)
        {
            ResponseDTO <bool> response = new ResponseDTO <bool>();

            // Convert token into Guid
            Guid tokenGuid;

            try
            {
                tokenGuid = new Guid(request.Token);
            }
            catch
            {
                response.Data  = false;
                response.Error = ErrorStrings.REQUEST_FORMAT;
                return(response);
            }

            // Check session in data store
            ResponseDTO <Session> sessionResponseDTO = _sessionService.GetSession(tokenGuid);

            // If session is not found, return error
            if (sessionResponseDTO.Data == null)
            {
                response.Data  = false;
                response.Error = sessionResponseDTO.Error;
                return(response);
            }

            // Check if user is currently disabled
            if (!sessionResponseDTO.Data.UserAccount.IsActive)
            {
                response.Data  = false;
                response.Error = ErrorStrings.USER_DISABLED;
                return(response);
            }

            return(_userManagementService.AcceptTOS(sessionResponseDTO.Data.UserAccount.Id));
        }