-
Notifications
You must be signed in to change notification settings - Fork 3
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
Implement login interface #77
Conversation
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 good! I have few questions mostly regarding the front-end.
src/app/src/constants.js
Outdated
@@ -38,3 +38,8 @@ export const PANES = { | |||
MUNICIPAL_BOUNDARY_LABELS: { label: 'muni-labels', zIndex: 225 }, | |||
USER_POLYGON: { label: 'user-polygon', zIndex: 490 }, | |||
}; | |||
|
|||
export const URLS = { |
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.
export const URLS = { | |
export const API_URLS = { |
We might eventually want to extract the frontend route names to a constant in which case URLS
might be confusing.
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.
src/django/api/views.py
Outdated
def post(self, request, *args, **kwargs): | ||
logout(request) | ||
|
||
return Response(status=status.HTTP_204_NO_CONTENT) |
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.
Can we split this file up like we did models.py?
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.
Taking a look now |
src/app/src/App.js
Outdated
function App() { | ||
return ( | ||
<BrowserRouter> | ||
<Flex> | ||
<Routes> | ||
<Route path='/draw' element={<Sidebar />} /> | ||
<Route | ||
path='/draw' |
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.
Interestingly, /draw
does redirect me, but /draw/
(which I usually use) does not.
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.
This is concerning: apparently, this is the request axios is making, which obviously fails because there are no endpoints exposed under /draw/
.
GET http://localhost:4545/draw/api/auth/login/ 404 (Not Found)
I'll troubleshoot on Monday, but let me know if anything comes to mind immediately.
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.
Actually, c97adef seemed to do it.
src/app/src/theme.js
Outdated
loginError: { | ||
fontSize: 'md', | ||
alignItems: 'center', | ||
color: 'red', |
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.
This could use some design input from @gatesgodin. It currently isn't legible against the gray background:
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.
Also @gatesgodin if you have an opinion about using placeholder text for email and password instead of labels above the inputs I'm interested in that as well (see screenshot at top of PR).
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.
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.
This is looking great! There's a couple of design changes to go through, but great job overall.
src/app/src/pages/Login.js
Outdated
<Button | ||
w='320px' | ||
variant='cta' | ||
onClick={() => loginRequest(email, password)} | ||
> | ||
Login | ||
</Button> | ||
<Button variant='link'>Forgot password?</Button> |
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.
Consider wrapping these buttons in a smaller VStack since they should have less spacing between them
<Button | |
w='320px' | |
variant='cta' | |
onClick={() => loginRequest(email, password)} | |
> | |
Login | |
</Button> | |
<Button variant='link'>Forgot password?</Button> | |
<VStack spacing={2}> | |
<Button | |
w='320px' | |
variant='cta' | |
onClick={() => loginRequest(email, password)} | |
> | |
Login | |
</Button> | |
<Button variant='minimal'>Forgot password?</Button> | |
</VStack> |
Where minimal
is a new Button variant that matches the wireframes:
minimal: {
fontWeight: 400,
fontSize: 'sm',
textDecoration: 'none',
color: 'gray.800',
},
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.
@gatesgodin did we consider the possibility of underlining all text links in the app? My concern was that if we leave "Forgot password?" without underlining then we introduce a small inconsistency and a small accessibility/usability issue, but I'm persuadable, since "Forgot password?" is such a common web interaction.
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'm going to apply Terence's diff (thank you!), and we can always add underlining back later if desired.
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.
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.
@jacobtylerwalls Hey! If we change the login page background to Grey-50 and the error message to Red-600 it will meet AAA color contrast requirements.
For the links, I'm open to underline the 'Forgot password'. There aren't many links within this app, but I do agree that they should be underlined if any surface throughout the development.
For the form labels, typically if there are 2 or less fields I opt to have the label as the placeholder for a cleaner look. Although if the form field has specific formatting (like a phone number) or many fields, then I would say that it's important to show the fields. Feel free to add them in if time permits.
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.
Great, I used red-600 and gray-50 in 4ccf042.
I'll add the underlining back in. This is the only text link so far:
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.
This looks really great! Nice job getting all the little details in.
I would recommend considering the URL redirect for logging in. Once that is in, this should be good to go!
Taking a final look |
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.
+1 tested, this looks really good! Great work on this, with all the fixup commits and being so responsive. Would recommend making sure the fixups merge correctly!
src/django/api/views/auth.py
Outdated
class Login(LoginView): | ||
permission_classes = (AllowAny,) | ||
|
||
@method_decorator(ensure_csrf_cookie) |
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.
Is this required here? Since we already have the middleware installed?
iow-boundary-tool/src/django/iow/settings.py
Line 108 in 8ee6d54
'django.middleware.csrf.CsrfViewMiddleware', |
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.
It was required with my first attempt at axios integration, but I'll give it another look if still needed.
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.
From the CSRF reference, it's not clear to me that the cookie is always sent with the response. Before posting the PR, I found that re-logging in at /login would sometimes fail, as the user was already in an authenticated session, and adding ensure_csrf_cookie
fixed it. Later, using the correct axios
integration seemed to take care of that, and plus--now you are redirected away from /login
if you're logged in. So I'll take it out 👍🏻
if not request.user.is_active: | ||
raise AuthenticationFailed("Unable to sign in") | ||
|
||
return Response(status=status.HTTP_204_NO_CONTENT) |
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.
In the future we may change this to return some user details (like Role, etc) for the front-end. Fine for now.
87fc4af
to
b5e950a
Compare
b5e950a
to
6ab4143
Compare
Overview
Implement login interface.
dj-rest-auth
api/auth/login
andapi/auth/logout
Closes #66
Demo
Notes
await
the/login
requests, so let me know if that is desired.dj-rest-auth
is the currently maintained fork ofdjango-rest-auth
, which will not be compatible with Django 4.aria-label
susername
field of the /login endpoint: it appears to work just fine (EDIT: well, it works using the dj-rest-auth endpoint, not the session-based django endpoint, and now only the django endpoint is exposed as of 8039f8f). Let me know if it's worth expending effort here to hide the username field.Testing Instructions
./scripts/update
./scripts/server
Checklist
fixup!
commits have been squashedCHANGELOG.md
updated with summary of features or fixes, following Keep a Changelog guidelinesREADME.md
updated if necessary to reflect the changes