Exemple #1
0
        public object Authenticate(string username, string password)
        {
            if (String.IsNullOrEmpty(username) ||
                String.IsNullOrEmpty(password))
            {
                return(BadRequest(
                           new ErrorDetails
                {
                    Code = (int)ErrorCodes.InvalidInputParameters,
                    Message = "invalid credentials"
                }
                           ));
            }

            object result = null;

            try
            {
                result = Ok(DataProcessor.AuthenticateUser(username, password));
            }
            catch (CouchbaseException cex)
            {
                result = BadRequest(
                    new ErrorDetails {
                    Code    = (int)ErrorCodes.CouchbaseProcessing,
                    Message = cex.Message
                }
                    );
            }
            catch (Exception ex)
            {
                result = BadRequest(
                    new ErrorDetails
                {
                    Message = $"Something failed: {ex.Message}",
                    Code    = (int)ErrorCodes.Unknown
                }
                    );
            }
            return(result);
        }