Repository: Wulf/create-rust-app (language: rust)

Issue:
Boileplate frontend fixes
Two small fixes we need to make to the generated front-end:

- [ ] the activation page doesn't pickup the `?token=` query parameter.
  - fetch token from url params, introduce a useQueryParam() hook
- [ ] the login request should have "device" set to "web"
Not found error for a recovery url
Hi,

I followed the steps to install the app and started a project. My steps -

1. create-rust-app bookmarks
2. selected `poem` as a backend
3. deselected `Container Plugin: dockerize your app` and  `Storage Plugin: adds S3 file storage capabilities`
4. updated env and ran `cargo fullstack`

I was able to register. But, the activation link `http://localhost:8080/activate?token=eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJleHAiOjE2NTI1MzQ0MjYsInN1YiI6MSwidG9rZW5fdHlwZSI6ImFjdGl2YXRpb25fdG9rZW4ifQ.-CMs1vftV31TRVFd1ZotDU5yWpRlR2DbUJGvMg9eN2o' when pasted in browser gave `not found` response. So, I changed the port to 3000 and pasted the token in the input box.
Then, I clicked on forgot password. An email was dispatched and printed on the console. I copied the link from the console. My link was 

`http://localhost:8080/reset?token=eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJleHAiOjE2NTAwMjgyNjUsInN1YiI6MSwidG9rZW5fdHlwZSI6InJlc2V0X3Rva2VuIn0.QhSunPvvFm2QVmK38_KLZJW0X7QxtN-1_jWwzO9ovyo`

I clicked the link and response was `not found`

So, I tried 

`http://127.0.0.1:3000/reset?token=eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJleHAiOjE2NTAwMjgyNjUsInN1YiI6MSwidG9rZW5fdHlwZSI6InJlc2V0X3Rva2VuIn0.QhSunPvvFm2QVmK38_KLZJW0X7QxtN-1_jWwzO9ovyo`. It worked!

So, how to fix this issue?


Discussion / hints:

hey @vishalsodani thanks a bundle for reporting this in such a detailed manner. Just wanted to say sorry for the inconvenience. There's a lot of work to be done when it comes to the default template.

A lot of what you described here relates to #35. If you have some time, I'd appreciate if you created a PR to fix these issues so the next user won't have to encounter them. In general, you can find all the files related to this in the [`create-rust-app_cli/template/frontend/src`](https://github.com/Wulf/create-rust-app/tree/main/create-rust-app_cli/template/frontend/src) folder -- those are the files that get copied to the created project. Let me know if I can help in anyway.

If you don't have the time, I completely understand. I'm going to try to implement a 'blank' template feature (see #26) and maybe I can address these issues at the same time.
Hi @Wulf Thanks for replying. It was so much fun to try out and see it work! After, I posted the bug I did see the issue #35. I would like to take a shot at fixing the issue. 
Can you please let me know how should I work in the  dev environment? I have cloned the repo and checked out the code. 
Should I debug by running `./target/debug/create-rust-app' ?
Yeah, that's how I develop as well -- here's a detailed breakdown:
- Create a dummy project via `create-rust-app ...`
- Make changes in the dummy project
- Run `git diff` to see what changed and copy over the changes to the right files in `create-rust-app_cli` (or wherever they belong)
- Install the local version of the CLI (`cargo install --path ./create-rust-app/create-rust-app_cli`)
- Generate another dummy project and see if everything runs the way it should
- Push :rocket:

I've been meaning to write documentation about this :sweat_smile:  (let me mention #32 here so I can revisit this conversation  when the time comes)

If you have any suggestions, I would love to hear them :)

Fix patch:
diff --git a/create-rust-app/src/auth/endpoints_poem.rs b/create-rust-app/src/auth/endpoints_poem.rs
index 63bb9571..d27ffa6e 100644
--- a/create-rust-app/src/auth/endpoints_poem.rs
+++ b/create-rust-app/src/auth/endpoints_poem.rs
@@ -575,7 +575,7 @@ async fn register(
         &mailer,
         &user.email,
         &format!(
-            "http://localhost:8080/activate?token={token}",
+            "http://localhost:3000/activate?token={token}",
             token = token
         ),
     );
@@ -687,7 +687,7 @@ async fn forgot_password(
             .unwrap();
 
         let link = &format!(
-            "http://localhost:8080/reset?token={reset_token}",
+            "http://localhost:3000/reset?token={reset_token}",
             reset_token = reset_token
         );
         mail::auth_recover_existent_account::send(&mailer, &user.email, link);
diff --git a/create-rust-app_cli/template-plugin-auth/frontend/src/containers/ActivationPage.tsx b/create-rust-app_cli/template-plugin-auth/frontend/src/containers/ActivationPage.tsx
index 24af667b..4db026cb 100644
--- a/create-rust-app_cli/template-plugin-auth/frontend/src/containers/ActivationPage.tsx
+++ b/create-rust-app_cli/template-plugin-auth/frontend/src/containers/ActivationPage.tsx
@@ -1,11 +1,13 @@
 import React, { useState } from 'react'
 import { useHistory } from 'react-router'
 import { useAuth } from '../hooks/useAuth'
+import { useQueryParam } from '../hooks/useQueryParam'
 
 export const ActivationPage = () => {
   const auth = useAuth()
   const history = useHistory()
-  const [activationToken, setActivationToken] = useState<string>('')
+  const token = useQueryParam('token') || '';
+  const [activationToken, setActivationToken] = useState<string>(token)
   const [processing, setProcessing] = useState<boolean>(false)
 
   const activate = async () => {


Test patch: