MATRIX Authentication framework for Swift
- iOS 8.0+
- Xcode 8.1, 8.2, 8.3, 9.0
- Swift 3.0, 3.1, 3.2, 4.0
To integrate MATRIX Auth SDK into your Xcode project using CocoaPods, specify it in your Podfile
:
pod 'MatrixAuthSDK'
Then, run the following command:
$ pod install
The starting point is MatrixAuth
. With it you can:
- Authenticate an existing user and work with it via
UserAuth
- Create a new user with given credentials and a role
- Request a password reset for a user, which they can then do via email
let auth = try MatrixAuth(clientId: ..., clientSecret: ...)
let username = "[email protected]"
let password = ...
auth.authenticate(username: username, password: password) { result in
switch result {
case let .success(user):
// Do stuff with user
...
case let .failure(error):
// Authentication failure; handle error
...
}
}
let user: UserAuth = ...
user.details { result in
switch result {
case let .success(details):
// Prints the details of the user as returned by the AdMobilize API
print(details)
case let .failure(error):
// Handle error
...
}
}
let user: UserAuth = ...
let device: String = ...
user.deviceSecret(for: device) { result in
switch result {
case let .success(secret):
// Prints the secret for `device` belonging to `user`
print(secret)
case let .failure(error):
// Handle error
...
}
}
let auth: MatrixAuth = ...
auth.registerNewUser(username: ..., password: ..., role: ...) { result in
switch result {
case let .success(value):
// Do stuff with API response
...
case let .failure(error):
// Handle error
...
}
}
After this, an email will be sent to the user asking them to reset their password.
let auth: MatrixAuth = ...
auth.forgotPassword(username: ...) { result in
switch result {
case let .success(value):
// Do stuff with API response
...
case let .failure(error):
// Handle error
...
}
}
This project is released under the MIT License.