MatrixAuthSDK 2.0.1

MatrixAuthSDK 2.0.1

测试已测试
Lang语言 SwiftSwift
许可证 MIT
发布最后发布2017年10月
SwiftSwift 版本4.0
SPM支持 SPM

Leonardo Vernaza 维护。



 
依赖
Alamofire~> 4
JSONWebToken~> 2
Result~> 3
 

MATRIX Swift Auth SDK

MATRIX 为 Swift authentication 框架





要求

  • iOS 8.0+
  • Xcode 8.1, 8.2, 8.3, 9.0
  • Swift 3.0, 3.1, 3.2, 4.0

用法

起点是 MatrixAuth。通过它您可以

  • 通过 UserAuth 验证现有用户并与之交互
  • 使用给定的凭据和角色创建新用户
  • 请求用户的密码重置,然后他们可以通过电子邮件执行此操作

用户认证

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
        ...
    }
}

用户密码重置

之后,将向用户发送电子邮件,要求他们重置密码。

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
        ...
    }
}

许可证

该项目在 MIT 许可证 下发布。