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

Create, Login and Logout #28

Open
samjam48 opened this issue Dec 13, 2019 · 0 comments
Open

Create, Login and Logout #28

samjam48 opened this issue Dec 13, 2019 · 0 comments
Assignees
Labels
enhancement New feature or request

Comments

@samjam48
Copy link

Your getting so close! Creating a user works. Logging in works. You just need to connect them up together check the user exists and should be allowed to log in. Then add a log out option

Creating a user
Validation, as the user focuses out, is great.

  1. You could add a similar function checkUser() to run on username field focusout to check if they exist in the database details, then display an error before they submit.
  2. Once user is created and you get a success from the DB (try returning id if you like) then run the login function with the created users details to set a cookie and direct to the trivia page

Login allows any user
Currently, login allows anyone (Nice work on setting a cookie to keep them logged in).
You could pull the table to the front end and search through the users and check if username and password exist, but this would send the user all the details of your users and their passwords so not cool, keep this in your server and just send the user a cookie if they are legit.

Try and write an SQL query that finds a user where name and password matches.
SELECT id FROM users WHERE name=_NAME_, pass=_PASS_;

(Or you could write two queries. One to check user exists. If does not exist show a not found user error. If they do exist run a second query to check password is correct for that user)

Logout function

  1. create logout button on trivia page
  2. create /logout route - call logout handler
  3. create /logout handler - clear cookie and send to user to home page
@samjam48 samjam48 added the enhancement New feature or request label Dec 13, 2019
@rosalie-baxter rosalie-baxter self-assigned this Dec 13, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

2 participants