Code Monkey home page Code Monkey logo

loginkit's Introduction

LoginKit

Version License Platform

LoginKit is a quick and easy way to add a Login/Signup UX to your app.

LoginKit handles Signup & Login, via Facebook & Email. It takes care of the UI, the forms, validation, and Facebook SDK access. All you need to do is start LoginKit, and then make the necessary calls to your own backend API to login or signup.

Requirements

Installation

LoginKit is available through CocoaPods. To install it, simply add the following line to your Podfile:

pod "ILLoginKit"

Getting Started

Login Coordinator

Everything is handled through the LoginCoordinator class. You insantiate it and pass the root view controller which is the UIViewController from which the LoginKit process will be started (presented) on. This will usually be self.

import LoginKit

class ViewController: UIViewController { 

  lazy var loginCoordinator: LoginCoordinator = {
    return LoginCoordinator(rootViewController: self)
  }()

  func showLogin() {
     loginCoordinator.start()
  }

}

Afterwards call start on the coordinator. That's it!

Customization

Of course you will want to customize the Login Coordinator to be able to supply your own UI personalization, and to perform the necessary actions on login or signup.

That is done by subclassing creating your own login coordinator subclassing the LoginCoordinator class.

import LoginKit

class MyLoginCoordinator: LoginCoordinator {
  
    // MARK: - Override these to customize the UI
  
    override var backgroundImage: UIImage {
        return UIImage()
    }

    override var logoImage: UIImage? {
        return UIImage()
    }
    
    //MARK: - Override these methods to handle login via your own API.
    
    override func login(email: String, password: String) {
        print("EMAIL = \(email), PASSWORD = \(password)")
        finish()
    }

    override func signup(name: String, email: String, password: String) {
        print("NAME = \(name), EMAIL = \(email), PASSWORD = \(password)")
        finish()
    }

    override func enterWithFacebook(profile: FacebookProfile) {
        print("FACEBOOK PROFILE = \(profile)")
        finish()
    }

    override func recoverPassword(email: String) {
        print("EMAIL = \(email)")
        finish()
    }
  
}

All these overriden methods return everything you need to handle login or signup on your end. The enterWithFacebook(profile:) method hands you a FacebookProfile struct which holds the Name, Email, and Facebook ID of the user's Facebook account, if they chose to enter with that method.

After successfull login call the finish() method on LoginCoordinator.

Author

Daniel Lozano, [email protected]

License

LoginKit is available under the MIT license. See the LICENSE file for more info.

loginkit's People

Contributors

danlozano avatar

Stargazers

 avatar

Watchers

 avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.