Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Consolidate the login code to the session store #120

Open
wants to merge 2 commits into
base: main
Choose a base branch
from

Conversation

pstaabp
Copy link
Member

@pstaabp pstaabp commented Aug 28, 2022

When logging in if the user is authenticated, there are still a number of things that occur

  1. storing the user in the session
  2. fetching user courses
  3. fetching roles & permissions

Although this only needs to be done once, the store tests should be logging in as a non-admin for better testing and these steps need to be done for each test. Therefore, all of these steps are pulled into a single login action in the session store.

WIP: create inflator and subsequent code cleanup.
Copy link
Member

@drdrew42 drdrew42 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Create and export a constant for the default user -- to be used in testing, login failure, and logout.

@@ -34,15 +38,15 @@ export class User extends Model {
get all_field_names(): string[] { return User.ALL_FIELDS; }
get param_fields(): string[] { return []; }

constructor(params: ParseableUser = {}) {
constructor(params: ParseableUser = { user_id: 0, username: '', is_admin: false }) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

username: logged_out?

Perhaps export this default as a constant for use in session.ts?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That's a good idea

course: CourseInfo;
user_courses: ParseableUserCourse[];
}

const logged_out_user = { username: 'logged_out', user_id: 0, is_admin: false };
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

import default user from model/users.ts

@@ -39,14 +38,10 @@ describe('Session Store', () => {
is_admin: false,
};

const logged_out: ParseableUser = {
const logged_out: SessionUser = {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

import from model/users.ts

WIP: added a default_session_user
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants