-
Notifications
You must be signed in to change notification settings - Fork 4
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
Issue 150 store token from server in local storage #155
Issue 150 store token from server in local storage #155
Conversation
The latest updates on your projects. Learn more about Vercel for Git ↗︎
|
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.
Have some console.log
that should be removed probably, but looks pretty good!
client/src/pages/sign-in.tsx
Outdated
@@ -61,7 +72,7 @@ export default function SignIn({ account }: { account: string }) { | |||
<SingleLineInput | |||
type="text" | |||
name="account" | |||
label="Email or mobile" | |||
label="Username" |
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.
Replace with Email or mobile, "username" is not usually associated with emails or mobile but actual user names like SodaVolcano, can be confusing
…issue-150-Store_token_from_server_in_local_storage_RAM_or_cookie_idk_-_Sign_in_and_Sign_up
const LOGIN_URL = LocalBaseURL.concat("/app/login/"); | ||
|
||
const handleLogin = async (username: string, password: string) => { | ||
const response = await axios.post(LOGIN_URL, { |
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.
Should we use the api
in the lib?
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.
I wrote this so I use it. It works well
To satisfy current fields in db, have to use username to login. Needs to change later |
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.
Looks pretty good, remove the validation if you want (can always go back to a previous commit if we need the regex pattern again)
client/src/pages/sign-in.tsx
Outdated
const isEmail = /^[a-zA-Z\._'\d-]+@[a-zA-Z]+(\.[a-zA-Z]+)+$/.test( | ||
formData.account, | ||
); | ||
const isPhone = /^[0-9]{10}$/.test(formData.account); | ||
|
||
if (!isEmail && !isPhone) { | ||
setErrorMessage("Invalid email or phone number. Please try again."); | ||
return; | ||
} | ||
// if (!isEmail && !isPhone) { | ||
// setErrorMessage("Invalid email or phone number. Please try again."); | ||
// return; | ||
// } |
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.
Feel free to remove validation if you think it should be done only on the server side. I guess we have to send the details to the server anyway so it doesn't matter if we also validate it there as well.
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.
Ok thanks now they only use username to login. I'll change later
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.
Now the login API uses username in the payload. I'll change later
Someone else is working on this signup page #134
Then go to |
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.
please fix the conflict : )
…issue-150-Store_token_from_server_in_local_storage_RAM_or_cookie_idk_-_Sign_in_and_Sign_up The changes in #110 made signin page unable to submit so I discarded these changes
…M_or_cookie_idk_-_Sign_in_and_Sign_up' and 'main' of https://github.com/codersforcauses/penni into issue-150-Store_token_from_server_in_local_storage_RAM_or_cookie_idk_-_Sign_in_and_Sign_up
Change Summary
sign-in.tsx
page.index.tsx
, got task list from db API using axios interceptor in/lib/api.ts
new-task.tsx
, got error responseform.tsx
andinput.tsx
bc Show/warn about required fields not being filled in in forms #110 made some changes that affect thesign-in.tsx
Change Form
Fill this up (NA if not available). If a certain criteria is not met, can you please give a reason.
Other Information
sign-in.tsx
Related issue