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
- Apple OAuth Scopes
Hi Hi, I've configured sign in with apple and this is the response i'm getting from apple once i've signed in. I cant find anywhere I set scopes. I remember se...
- Sign In With Apple OAuth Help
Hi All! I've got a flutter & appwrite app which Im trying to use sign in with apple for. I already have sign in with google working and the function is the sam...
- [SOLVED] OAuth With Google & Flutter
Hi all, I'm trying to sign in with google and it all goes swimmingly until the call back. I get a new user created on the appwrite dashboard however the flutte...