hackforla / HomeUniteUs

We're working with community non-profits who have a Host Home or empty bedrooms initiative to develop a workflow management tool to make the process scalable (across all providers), reduce institutional bias, and effectively capture data.
https://homeunite.us/
GNU General Public License v2.0
36 stars 21 forks source link

Style adjustments in preparation for section 1 #562

Closed erikguntner closed 9 months ago

erikguntner commented 10 months ago

Apologies ahead of time since this includes a lot of different style adjustments while preparing for the section 1 demo, and is a bit all over the place.

The main parts are:

Joshua-Douglas commented 10 months ago

Hey @erikguntner,

Looking forward to giving this a deeper review, but I have a few question first.

Should I be able to create a new login and actually sign in using this PR?

I was able to build the project locally, and use the Sign Up form, but I receive a silent error when attempting to create a new user.

If I enter a valid email address and password I do not see any error message on the form, but I do see an exception in the API console logs (shown below). If I attempt to re-submit this same form, I get a new error message: A user with this email already exists.

I also do not receive any email, and I am not able to use this login/pass to sign in (I get error "incorrect user/password").

2023-08-06 18:52:37,076 INFO sqlalchemy.engine.Engine BEGIN (implicit)
2023-08-06 18:52:37,076 INFO sqlalchemy.engine.Engine INSERT INTO user (email) VALUES (?)
2023-08-06 18:52:37,077 INFO sqlalchemy.engine.Engine [cached since 268s ago] ('4gxixhg2@duck.com',)
2023-08-06 18:52:37,077 INFO sqlalchemy.engine.Engine COMMIT
127.0.0.1 - - [06/Aug/2023 18:52:37] "POST /api/auth/signup/host HTTP/1.1" 500 -
Traceback (most recent call last):
  File "/home/joshuad1434/hackforla/HomeUniteUs/api/openapi_server/controllers/auth_controller.py", line 109, in signUpHost
    response = userClient.sign_up(
  File "/home/joshuad1434/hackforla/HomeUniteUs/api/.venv/lib/python3.10/site-packages/botocore/client.py", line 508, in _api_call
    return self._make_api_call(operation_name, kwargs)
  File "/home/joshuad1434/hackforla/HomeUniteUs/api/.venv/lib/python3.10/site-packages/botocore/client.py", line 874, in _make_api_call
    request_dict = self._convert_to_request_dict(
  File "/home/joshuad1434/hackforla/HomeUniteUs/api/.venv/lib/python3.10/site-packages/botocore/client.py", line 935, in _convert_to_request_dict
    request_dict = self._serializer.serialize_to_request(
  File "/home/joshuad1434/hackforla/HomeUniteUs/api/.venv/lib/python3.10/site-packages/botocore/validate.py", line 381, in serialize_to_request
    raise ParamValidationError(report=report.generate_report())
botocore.exceptions.ParamValidationError: Parameter validation failed:
Invalid type for parameter ClientMetadata.url, value: None, type: <class 'NoneType'>, valid types: <class 'str'>

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/home/joshuad1434/hackforla/HomeUniteUs/api/.venv/lib/python3.10/site-packages/flask/app.py", line 2551, in __call__
    return self.wsgi_app(environ, start_response)
  File "/home/joshuad1434/hackforla/HomeUniteUs/api/.venv/lib/python3.10/site-packages/flask/app.py", line 2531, in wsgi_app
    response = self.handle_exception(e)
  File "/home/joshuad1434/hackforla/HomeUniteUs/api/.venv/lib/python3.10/site-packages/flask/app.py", line 2528, in wsgi_app
    response = self.full_dispatch_request()
  File "/home/joshuad1434/hackforla/HomeUniteUs/api/.venv/lib/python3.10/site-packages/flask/app.py", line 1825, in full_dispatch_request
    rv = self.handle_user_exception(e)
  File "/home/joshuad1434/hackforla/HomeUniteUs/api/.venv/lib/python3.10/site-packages/flask/app.py", line 1823, in full_dispatch_request
    rv = self.dispatch_request()
  File "/home/joshuad1434/hackforla/HomeUniteUs/api/.venv/lib/python3.10/site-packages/flask/app.py", line 1799, in dispatch_request
    return self.ensure_sync(self.view_functions[rule.endpoint])(**view_args)
  File "/home/joshuad1434/hackforla/HomeUniteUs/api/.venv/lib/python3.10/site-packages/connexion/decorators/decorator.py", line 68, in wrapper
    response = function(request)
  File "/home/joshuad1434/hackforla/HomeUniteUs/api/.venv/lib/python3.10/site-packages/connexion/decorators/uri_parsing.py", line 149, in wrapper
    response = function(request)
  File "/home/joshuad1434/hackforla/HomeUniteUs/api/.venv/lib/python3.10/site-packages/connexion/decorators/validation.py", line 196, in wrapper
    response = function(request)
  File "/home/joshuad1434/hackforla/HomeUniteUs/api/.venv/lib/python3.10/site-packages/connexion/decorators/parameter.py", line 120, in wrapper
    return function(**kwargs)
  File "/home/joshuad1434/hackforla/HomeUniteUs/api/openapi_server/controllers/auth_controller.py", line 119, in signUpHost
    code = e.response['Error']['Code']
AttributeError: 'ParamValidationError' object has no attribute 'response'

I can try diagnosing the issue - but just want to make sure that it works on your side first.

Are you able to build the app dockerfile?

I run across a cryptic error message when attempting to build the app dockerfile. I see this error on main as well, and across Windows and Linux builds.

 => ERROR [app builder 6/6] RUN npm run build                                                                                                                               9.7s
------
 > [app builder 6/6] RUN npm run build:
0.620
0.620 > home-unite-us@1.0.0 build
0.620 > tsc && vite build
0.620
9.652 error during build:
9.652 RangeError: Maximum call stack size exceeded
9.652     at String.match (<anonymous>)
9.652     at interpolate (file:///app/node_modules/vite/dist/node/chunks/dep-2faf2534.js:45395:28)
9.652     at file:///app/node_modules/vite/dist/node/chunks/dep-2faf2534.js:45413:17
9.652     at Array.reduce (<anonymous>)
9.652     at interpolate (file:///app/node_modules/vite/dist/node/chunks/dep-2faf2534.js:45397:20)
9.652     at file:///app/node_modules/vite/dist/node/chunks/dep-2faf2534.js:45413:17
9.652     at Array.reduce (<anonymous>)
9.652     at interpolate (file:///app/node_modules/vite/dist/node/chunks/dep-2faf2534.js:45397:20)
9.652     at file:///app/node_modules/vite/dist/node/chunks/dep-2faf2534.js:45413:17
9.652     at Array.reduce (<anonymous>)

Should password recovery work with a local build?

When I request a password reset on a newly created account that I've never logged into, I do see the "Verification Code" page but I never receive an email with the code.

Attempts to resend the validation code gives me the successful message A new code has been sent to your email..

erikguntner commented 10 months ago

@Joshua-Douglas thanks for taking the time to give this a look! You should be able to sign up and go through the other flows of signing in and resetting your password as well. I just went through them on my machine and had no issues.

So I think the A user with this email already exists is happening because the user is successfully getting created in AWS and in the db. However, you won't be able to sign in unless your account is verified, which can't be done unless you get the emails 😅 Have you checked your spam folder by chance? They may have ended up there. And do you have a ROOT_URL variable in your .env?

I haven't been using Docker to run the project, just npm run dev for the client and python3 -m openapi_server for the server.

erikguntner commented 10 months ago

Attempts to resend the validation code gives me the successful message A new code has been sent to your email.

@Joshua-Douglas This should almost always give you a success message unless you try too many times. I think it's done this way so people can't enter a bunch of emails and find out if they exist in the system or not

Joshua-Douglas commented 10 months ago

Awesome! I did receive the verification email once I set the ROOT_URL environment variable.

The verification also worked as expected and I was able to sign in. The email I received did have some minor formatting errors. The confirm button was mostly cutoff, and I was barely able to click it:

image

erikguntner commented 9 months ago

@Joshua-Douglas Google auth is working for me. I'll Slack you my .env and let me know if that fixes anything for you.

Joshua-Douglas commented 9 months ago

Hey @erikguntner,

Is google auth working on other machines, like the recent dev deployment? I was able to get google auth working on my machine, but it required a source code change.

I noticed that cognito was returning a redirect_mismatch error, so I read the docs a bit and found that you are only able to redirect to URLs that are explicitly registered with client id. With this info in mind I tried updating the redirect URL from http://localhost:4040/signup/${type} to http://localhost:4040/signup and the google authentication work.

This seems to indicate that the http://localhost:4040/signup/host and http://localhost:4040/signup/coordinator URLs are not registered with the cognito user, but the http://localhost:4040/signup/ is.

It is odd that auth is still working on your machine though, since we are using the same COGNITO_CLIENT_ID. I wonder if something else is going on here.

erikguntner commented 9 months ago

@Joshua-Douglas super odd. These are all of the redirect urls I have registered with Cognito client:

Screenshot 2023-08-09 at 1 00 06 PM
erikguntner commented 9 months ago

@Joshua-Douglas http not https for localhost 🤦‍♂️. I updated it if you wanna give it another try

erikguntner commented 9 months ago

@Joshua-Douglas made a commit that replaces references to localhost on the front end with ROOT_URL on the backend and I think resolves the Google auth issues