Authenticate your users
Create your auth instance
This instance is used to manage authentication with Viafoura
let auth = ViafouraSDK.auth()
Get user auth status
Retrieve the current user auth status.
auth.getUserLoginStatus(completion: { result in
switch result {
case .success(let loginStatus):
if case .loggedIn(let userUUID) = loginStatus {
} else if case .notLoggedIn = loginStatus {
}
case .failure(let error):
print(error.localizedDescription)
break
}
})
LoginStatus | Value |
---|---|
notLoggedIn | User is not currently logged in |
loggedIn | User is currently logged in |
Logout
Log the user out.
auth.logout()
Basic login
Perform basic login with e-mail and password.
auth.login(
email: email, password: password,
completion: { result in
switch result {
case .success(let loginData):
case .failure(let loginError):
print(loginError.errorDescription)
}
})
Basic signup
auth.signup(
name: name, email: email, password: password,
completion: { result in
switch result {
case .success(let signUpData):
case .failure(let signUpError):
print(signUpError.errorDescription)
}
})
Cookie login
More information about how our cookie login works: Cookie Login
auth.cookieLogin(token: token, completion: { result in
switch result {
case .success(let cookieLoginData):
case .failure(let cookieLoginError):
print(cookieLoginError.errorDescription)
}
})
OpenID login
More information about how our OIDC login works: OIDC Login
auth.openIdLogin(token: token, completion: { result in
switch result {
case .success(let openIdLoginData):
case .failure(let openIdLoginError):
print(cookieLoginError.errorDescription)
}
})
Login Radius login
auth.loginRadiusLogin(token: token, completion: { result in
switch result {
case .success(let openIdLoginData):
case .failure(let openIdLoginError):
print(cookieLoginError.errorDescription)
}
})
Social login
auth.socialLogin(token: token, completion: { result in
switch result {
case .success(let openIdLoginData):
case .failure(let openIdLoginError):
print(cookieLoginError.errorDescription)
}
})
Request password reset
auth.resetPassword(email: email, completion: { result in
switch result {
case .success(let result):
case .failure(let passwordResetError):
print(cookieLoginError.errorDescription)
}
})
Updated 9 months ago
What’s Next