Skip to content

Commit

Permalink
Fix initial token discrepancies.
Browse files Browse the repository at this point in the history
  • Loading branch information
liffiton committed Dec 20, 2024
1 parent e9f04b7 commit eb904d4
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 5 deletions.
2 changes: 1 addition & 1 deletion src/gened/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -118,7 +118,7 @@ def create_app_base(import_name: str, app_config: dict[str, Any], instance_path:
# Cache timeout for static files (seconds)
SEND_FILE_MAX_AGE_DEFAULT=3*60*60, # 3 hours
# Free query tokens given to new users
DEFAULT_TOKENS=10,
DEFAULT_TOKENS=20,

PYLTI_CONFIG={
# will be loaded from the consumers table in the database
Expand Down
4 changes: 2 additions & 2 deletions src/gened/lti.py
Original file line number Diff line number Diff line change
Expand Up @@ -95,8 +95,8 @@ def lti_login(lti: LTI) -> Response | tuple[str, int]: # noqa: ARG001 (unused a
'auth_name': None,
'ext_id': lti_id,
}
# LTI users given 0 tokens by default -- should only ever use API registered w/ LTI consumer
user_row = ext_login_update_or_create('lti', user_normed, query_tokens=10)
# LTI users given 0 tokens by default -- should only ever use API key registered w/ LTI consumer
user_row = ext_login_update_or_create('lti', user_normed, query_tokens=0)
user_id = user_row['id']

# check for and create role if needed
Expand Down
5 changes: 3 additions & 2 deletions src/gened/oauth.py
Original file line number Diff line number Diff line change
Expand Up @@ -114,8 +114,9 @@ def auth(provider_name: str) -> Response:

current_app.logger.debug(f"SSO login: {provider_name=} email='{user_normed['email']}' full_name='{user_normed['full_name']}'")

# Given 10 tokens by default if creating an account on first login.
user_row = ext_login_update_or_create(provider_name, user_normed, query_tokens=20)
# Create a new user (with default # of free tokens) or update the existing if matched
tokens = current_app.config.get('DEFAULT_TOKENS', 0)
user_row = ext_login_update_or_create(provider_name, user_normed, query_tokens=tokens)

# Get their last active class, if there is one (and it still exists and user has active role in it)
last_class_id = get_last_class(user_row['id'])
Expand Down

0 comments on commit eb904d4

Please sign in to comment.