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

4 admin page ish but async await makes this to be just a empty promise #165

Conversation

ruupert
Copy link
Contributor

@ruupert ruupert commented Apr 17, 2018

Short description

  • Adds middlewares for checking env variables TOKEN and SECRET at the start and stop processing any requests any further if they are not set.

  • Adds backend /admin page with a single purpose of activating/importing courses from upstream server to the application. Uses pug for views and http basic auth with username admin and password from the env variable ADMIN_PW. TODO: add another middleware to check that the ADMIN_PW is set or otherwise it might let in without password.

Adding courses works as following: Get courses for current and next term and select all courses matching from the DB and work out which of them isn't added. From those not added courses a pug page is rendered with a form for each not added course with a submit button, which posts the form values and they are entered into the DB as they are and while at it the course teachers user entries (with only username value) are added. This tries to insert into TeacherInstances appropriate links but currently FAILS in inserting the userId for some reason.

This should not break anything currently in the dev branch.

I have:

  • added actual code.
  • produced clean code.
  • code that actually does what it should.
  • documented the code or added documentation to the wiki.
  • added or modified test(s).
  • test(s) that actually pass.

simple <form> page behind basic auth where the user could enable courses
that are not activated yet. This shit got stuck at the typical javascript async await so to expand this behaviour to real life then this clearly is promised to be done and may or may not get done in time.
…th for user admin with password set in env ADMIN_PW variable.
… from upstream.

Problems:

 * Some courses might not have teacher at their creation lol
 * I bet that there are many more

TODO:

-> Create the course CourseInstance.create
 -> find each teacher user and create with incomplete data (findOrCreate by username).
    -> Use each created user id to link the user with the CourseInstance.

Finally, check that the login function fills in missing data for users...... and somehow also teacher memberships.
@ruupert
Copy link
Contributor Author

ruupert commented Apr 17, 2018

TeacherInstance link creation fixed

changing this back to how you use this by default.
@ruupert
Copy link
Contributor Author

ruupert commented Apr 17, 2018

Aslo has now a middleware that tells the user that ADMIN_PW environment variable needs to be set if unset.

Jest should be used since it is able to return exit code 0 for success and 1 for failure.
…be run in travis. Like first in order is the tests stage after which integration tests should be run.
const authorization = request.get('authorization')
if (authorization && authorization.toLowerCase().startsWith('bearer ')) {
request.token = authorization.substring(7)
} else {
}

Copy link
Contributor

Choose a reason for hiding this comment

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

Why is there if-else with empty else-statetment?!

}
} else {
}
Copy link
Contributor

Choose a reason for hiding this comment

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

AGAIN! sigh

@tjunno tjunno self-requested a review April 20, 2018 07:58
@tjunno
Copy link
Contributor

tjunno commented Apr 20, 2018

seems to work as intended after fixing some os based problems

Copy link
Contributor

@tjunno tjunno left a comment

Choose a reason for hiding this comment

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

seems to work as intended

@tjunno tjunno merged commit 5ce6f77 into dev Apr 20, 2018
@ruupert ruupert deleted the 4_admin_page_ish_but_async_await_makes_this_to_be_just_a_empty_promise branch April 20, 2018 09:23
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.

None yet

3 participants