-
Notifications
You must be signed in to change notification settings - Fork 8
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
base: main
Are you sure you want to change the base?
Conversation
WIP: create inflator and subsequent code cleanup.
ba84276
to
56a4c79
Compare
There was a problem hiding this 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 }) { |
There was a problem hiding this comment.
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?
There was a problem hiding this comment.
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
src/stores/session.ts
Outdated
course: CourseInfo; | ||
user_courses: ParseableUserCourse[]; | ||
} | ||
|
||
const logged_out_user = { username: 'logged_out', user_id: 0, is_admin: false }; |
There was a problem hiding this comment.
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
tests/stores/session.spec.ts
Outdated
@@ -39,14 +38,10 @@ describe('Session Store', () => { | |||
is_admin: false, | |||
}; | |||
|
|||
const logged_out: ParseableUser = { | |||
const logged_out: SessionUser = { |
There was a problem hiding this comment.
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
534c39e
to
9140472
Compare
When logging in if the user is authenticated, there are still a number of things that occur
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.