Hello! I am currently in the process of implementing password recovery. I am using Flutter. This is my code to send the recovery email in first place:
await _account.createRecovery(
email: email, url: 'http://localhost:5000/#/password-recovery');
However, there is a problem with it. When the mail was sent (I already set up smtp etc.), the url with the query paramters (userId and secret) looks like this:
http://localhost:5000/?userId=[userId]&secret=[secret]&expire=[expire]#/password-recovery
Notice, that the query paramters are not after the password-recovery, but directly after the "main" url. Before I even implemented password recovery (confirmation), I had this url just as an example:
http://localhost:8080/v1/account/recovery
The URL that I got in the mail looked like this:
http://localhost:8080/v1/account/recovery?userId=[userId]&secret=[secret]&expire=[expire]
Notice, that the query paramters are at the right place when using this url.
Anyone knows, what the issue could be?
That is because you're using a browser-side navigation.
What framework you're using?
You can see here https://github.com/appwrite/appwrite/blob/master/src/Appwrite/Template/Template.php#L123
That anything with the # will be append at the end of the URL.
This separation into a fragment is done by PHP own parse_url function
https://www.php.net/manual/en/function.parse-url.php
Flutter alongside go_router
Check this to set your router to be using path https://docs.page/csells/go_router/url-path-strategy
like so
GoRouter.setUrlPathStrategy(UrlPathStrategy.path);
Then you'll be able to send
await _account.createRecovery(email: email, url: 'http://localhost:5000/password-recovery');
Well that's interesting, I always wondered why there is a #, but never bothered because it worked great (till now) xD
Gonna try it
🙂 This is meant for servers that won't point all request to index file for processing. As Flutter in the web is a frontend.
Then if you have the # its like you're writing
http://localhost:5000/index.html#/password-recovery
And the JS framework will take care of it.
Now most servers knows how to point the whole path to the main file.
Like so
http://localhost:5000/index.html/password-recovery
ahh, interesting, thanks
I see that the link I gave you is for the original package.
Now the recommend way is to this
void main() {
usePathUrlStrategy(); // ‼️ this line
runApp(ExampleApp());
}
https://docs.flutter.dev/ui/navigation/url-strategies#configuring-the-url-strategy
yeah, I've also noticed that. But np, I also found the link ^^
Thank you very much Binyamin, it works now <:appwritepeepo:902865250427215882>
<:appwritefire:823999000330895380>
[SOLVED] Password Recovery query paramters inserted at wrong position
Recommended threads
- Synchronous Function Execution Timed Out...
Hi Appwrite team 👋 I’m facing a synchronous function execution timeout issue on Appwrite Cloud and would appreciate some guidance. I executed this function u...
- Push Notification FCM Error
Hello dear people. I tried to integrate Push Notifications into my Flutter App. Everything works fine on Android/iOS Simulator + Testflight but as soon as I s...
- Skip total counts crash the query
Hello, When adding the total parameter (either true, the default, or false) to the listRows function, it raises the following error: `type 'bool' is not a sub...