TestsTested | ✓ |
LangLanguage | SwiftSwift |
License | MIT |
ReleasedLast Release | Jul 2016 |
SPMSupports SPM | ✓ |
Maintained by Kieran Andrews.
Depends on: | |
Alamofire | ~> 3.0 |
SVProgressHUD | >= 0 |
KeychainAccess | >= 0 |
IQKeyboardManagerSwift | >= 0 |
LoginKit
library that helps you with user logins. It provides a login screen that is customizable. It currently works with JWT tokens and Basic Auth.
LoginKit is available through CocoaPods. To install it, simply add the following line to your Podfile:
pod "LoginKit"
If you want to use the latest features of LoginKit
use normal external source dependencies.
pod 'LoginKit', :git => 'https://github.com/TigerWolf/LoginKit.git'
This pulls from the master
branch directly. We are usually careful about what we push there and this is the version we use ourselves in all of our projects.
Second, install LoginKit
into your project:
pod install
LoginKit/LoginKit
folder into your project.LoginKit.bundle
is added to Targets->Build Phases->Copy Bundle Resources
.(see sample Xcode project in /Example
)
LoginKit
is created as a singleton (i.e. it doesn’t need to be explicitly allocated and instantiated; you directly call LoginKit.method
).
First set the config using LoginKitConfig
// Setup
LoginKitConfig.url = "https://example.com/token"
// lambda is to ensure controller is not executed until successful login.
LoginKitConfig.destination = = { ()-> UIViewController in PrivateController() }
// Load the login screen
let loginScreen = LoginKit.loginScreenController()
self.presentViewController(loginScreen, animated: false,completion: nil)
LoginKit
can be customized via the following methods:
Example:
Appearance.backgroundColor = UIColor(red: 0.46, green: 0.70, blue: 0.93, alpha: 1.0)
LoginKitConfig.logoImage = UIImage(named: "logo") ?? UIImage()
LoginKit
assumes that every web request within the app will check for authentication (in the case of an expired token or changed password). In order to make this easy, LoginKit
provides some utility classes for making requests to APIs which includes authentication sent with all requests as well as checks for expired tokens.
For example, after a user has logged in you can use the LoginService
to make further network requests:
LoginService.request(.GET, "api/v1/beers", parameters: nil).validate()
.responseJSON() { response in
if response.result.isSuccess {
let json = JSON(response.result.value!)
// Deal with JSON response here
}
// Error cases are handled in LoginService
}
Minimum iOS Target: iOS 8.0
Minimum Xcode Version: Xcode 7.2
If you have feature requests or bug reports, feel free to help out by sending pull requests or by creating new issues.
LoginKit
is distributed under the terms and conditions of the MIT license.
LoginKit
is brought to you by Kieran Andrews and Andreas Wulf and contributors to the project