Signing out of an App with Facebook or Email

Hi everyone,

Users can sign into my app via Facebook or with their email. Once they sign into the app, they are brought to the HomeVC where they have a sign out option.

Rather than having a separate Facebook sign out option and an email sign out option, does anyone know if it is possible to combine the signout logic into one button?
So for example, if a user is signed in with Facebook then they would press the same button to sign out as a user signed in with email.

If this doesn’t make sense please let me know and I’ll try to explain it better.

Thanks in advance!

You could define an enum which keeps track of the login source which you store in the HomeVC.

eg: You can create this outside of the class.

enum LoginSource {
    case facebook
    case email

in HomeVC add a property like so:

var loginSource = LoginSource.facebook // Default value

then when the user logs in (depending on which method they use) set the enum accordingly.

ie, if they logged in using email then after successfully logging in, you would set:
loginSource = .email

When they log out you could interrogate that enum:

if loginSource == .email {
    //  logout via email
} else {
    // logout via Facebook

Does that make sense?

1 Like