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
- listRows result parsing issue
I'm using Appwrite Dart SDK "24.2.0". When I perform a listRows call in dart, I have this reponse in JSON: in " Future<models.RowList> listRows()" { "total" :...
- Broken Flutter SDK >=24.1.0
Row.fromMap now does: ``` data: Map<String, dynamic>.from(map["data"] ?? {}) ``` But Appwrite Cloud TablesDB row responses return custom row columns flattene...
- Flutter OAuth2 does not attach Google se...
Hi Appwrite team, Iβm using Appwrite Auth in a Flutter mobile app and trying to upgrade an anonymous user to Google OAuth. Docs say that if there is already a...