Back

[SOLVED] Email login: From backend vs from client

  • 0
  • General
  • Accounts
  • Apple
  • Users
  • Self Hosted
Kilo Loco
2 Aug, 2023, 03:16

Should my backend be logging the user in by receiving the email and password from the client and then forwarding that information to Appwrite OR should the client be logging in directly and skipping my backend so it can obtain a Session object?

Background context: Backend is written is Swift using Vapor framework. Client is macOS and iOS also written in Swift. createEmailSession is not showing up in the SDK when using it on the backend, haven’t checked macOS/iOS yet. I’m relatively new to backend development so I may be missing some foundational knowledge.

TL;DR
The user is asking whether it is bad practice to have their server act as a middleman between the client and Appwrite for email login. They are worried about needing to rewrite the logic if they port their app to Android. The response suggests that it is usually better to have the front end talk directly to Appwrite. However, if the server is used as a middleman, the client can create a session and generate a JWT token to pass to the server for API calls. The user also mentions that they are not seeing the `createEmailSession` method in the SDK when using it on the backend. The issue seems to be resolved
Drake
2 Aug, 2023, 06:13

Usually people have their front end talk directly to Appwrite. If you have that swift server in the middle, you can use Appwrite like you would any other database and connect to it with an API key.

You can have the client create the session and then generate a JWT token to pass to your swift server to make API calls on behalf of the user.

Kilo Loco
2 Aug, 2023, 06:42

Understood. Thanks for the reply 🙏🏽 I just wanted to clarify, is it bad practice to have my server be the middleman between the client and Appwrite? My thinking was that if I port my app to Android, I wouldn’t have to worry about rewriting the logic.

Drake
2 Aug, 2023, 16:10

it's a tradeoff. i think it complicates things a lot putting that layer in the middle. Maybe you can use Functions for any complex logic (i'm not sure what kind of logic you need).

All the Appwrite SDKs work mostly the same so if you're porting, you'd call the same method.

Kilo Loco
3 Aug, 2023, 02:30

Got it. Thanks!!

Kilo Loco
3 Aug, 2023, 02:31

[SOLVED] Email login: From backend vs from client

Reply

Reply to this thread by joining our Discord

Reply on Discord

Need support?

Join our Discord

Get community support by joining our Discord server.

Join Discord

Get premium support

Join Appwrite Pro and get email support from our team.

Learn more