|
4 | 4 | from flask_bcrypt import check_password_hash |
5 | 5 | from email_validator import EmailNotValidError |
6 | 6 | from sqlalchemy.exc import SQLAlchemyError, IntegrityError |
7 | | -from configparser import NoOptionError |
8 | 7 | from pbench.server.database.models.users import User |
9 | 8 | from pbench.server.database.models.active_tokens import ActiveTokens |
10 | 9 | from pbench.server.api.auth import Auth |
@@ -139,13 +138,9 @@ def __init__(self, config, logger, auth): |
139 | 138 | self.server_config = config |
140 | 139 | self.logger = logger |
141 | 140 | self.auth = auth |
142 | | - try: |
143 | | - self.token_expire_duration = self.server_config.get( |
144 | | - "pbench-server", "token_expiration_duration" |
145 | | - ) |
146 | | - except NoOptionError: |
147 | | - # Defaults to 60 minutes |
148 | | - self.token_expire_duration = 60 |
| 141 | + self.token_expire_duration = self.server_config.get( |
| 142 | + "pbench-server", "token_expiration_duration" |
| 143 | + ) |
149 | 144 |
|
150 | 145 | @Auth.token_auth.login_required(optional=True) |
151 | 146 | def post(self): |
@@ -198,7 +193,7 @@ def post(self): |
198 | 193 | self.logger.warning( |
199 | 194 | "No user found in the db for Username: {} while login", username |
200 | 195 | ) |
201 | | - abort(403, message="No such user, please register first") |
| 196 | + abort(403, message="Bad login") |
202 | 197 |
|
203 | 198 | # Validate the password |
204 | 199 | if not check_password_hash(user.password, password): |
@@ -443,7 +438,7 @@ def put(self, username): |
443 | 438 | field, |
444 | 439 | post_data[field], |
445 | 440 | ) |
446 | | - abort(400, message="Invalid data in update request payload") |
| 441 | + abort(403, message="Invalid update request payload") |
447 | 442 | try: |
448 | 443 | user.update(**post_data) |
449 | 444 | except Exception: |
@@ -500,7 +495,7 @@ def delete(self, username): |
500 | 495 | else: |
501 | 496 | if user.is_admin(): |
502 | 497 | self.logger.warning("Admin attempted to delete admin user") |
503 | | - abort(405, message="Admin user can not be deleted") |
| 498 | + abort(403, message="Admin user can not be deleted") |
504 | 499 | self.logger.info("User entry deleted for user with username {}", username) |
505 | 500 |
|
506 | 501 | response_object = { |
|
0 commit comments