A row for Eureka to implement password validations.

Overview

GenericPasswordRow

Build status Platform iOS Swift 4 compatible Carthage compatible CocoaPods compatible License: MIT

By Xmartlabs SRL.

Contents

Introduction

GenericPasswordRow is a custom row for Eureka designed to create passwords. Its main purpose is to guide users through this process according to a set of validations.

  • Features
    • Visibility
    • Password strength
    • Hints

Usage

import Eureka
import GenericPasswordRow

class ViewController: FormViewController {

    override func viewDidLoad() {
        super.viewDidLoad()

        form +++ Section()
            <<< GenericPasswordRow()
    }
}

Requirements

  • iOS 9.0+
  • Xcode 11.5+
  • Eureka ~> 5.2.1

Getting involved

  • If you want to contribute please feel free to submit pull requests.
  • If you have a feature request please open an issue.
  • If you found a bug or need help please check older issues, FAQ and threads on StackOverflow (Tag 'GenericPasswordRow') before submitting an issue..

Before contribute check the CONTRIBUTING file for more info.

If you use GenericPasswordRow in your app we would love to hear about it! Drop us a line on twitter.

Examples

Follow these steps to run Example project:

  • Clone GenericPasswordRow repository
  • Open terminal in the downloaded folder and run bin/setup script
  • Open GenericPasswordRow workspace
  • Run the Example project.

Installation

CocoaPods

CocoaPods is a dependency manager for Cocoa projects.

To install GenericPasswordRow, simply add the following line to your Podfile:

pod 'GenericPasswordRow', '~> 3.1'

Carthage

Carthage is a simple, decentralized dependency manager for Cocoa.

To install GenericPasswordRow, simply add the following line to your Cartfile:

github "EurekaCommunity/GenericPasswordRow" ~> 3.1

Customization

For basic styling like fonts, colors, margins, separators you should use cellSetup and cellUpdate. Otherwise, you should be able to provide a completely different design (different nib file) and reuse the already implemented logic.

GenericPasswordRow parameters

  • var passwordValidator: PasswordValidator = DefaultPasswordValidator(): a PasswordValidator intended to define the rules to be satisfied by the password. See Implement custom validation
  • var placeholder: String? = "Password": placeholder of password textfield.

For example you can do this:

<<< GenericPasswordRow() {
      $0.passwordValidator = // instantiate your custom validator
      $0.placeholder = "Create a password"
  }

GenericPasswordCell parameters:

  • @IBOutlet weak var textField: UITextField!:
    Password textfield.
  • @IBOutlet weak var visibilityButton: UIButton?:
    Visibility button intended to toggle the secureTextEntry property of textField.
  • @IBOutlet weak var passwordStrengthView: PasswordStrengthView?:
    A subclass of PasswordStrengthView with the custom design of the strength indicator. See PasswordStrengthView
  • @IBOutlet weak var hintLabel: UILabel?:
    Label used to show hints to the user while typing his password.
  • var visibilityImage: (on: UIImage?, off: UIImage?):
    Images to be set to the visibilityButton depending on the textField's secureTextEntry state.
  • var dynamicHeight = (collapsed: UITableViewAutomaticDimension, expanded: UITableViewAutomaticDimension):
    Heights of the cell when collapsed (with hintLabel hidden) and expanded (hintLabel not hidden). This property is nib-specific.

Creating custom nib file

You might want to follow your own design. To accomplish this you should follow these steps:

  • Create a user interface xib file and edit it with Xcode's Interface Builder. You should add a simple UITableViewCell and say that its class is a GenericPasswordCell.

  • Add an UITextField for the password entry and connect it to the textField outlet.

  • [optional] Add an UIButton and connect it to the visibilityButton.

  • [optional] Add a PasswordStrengthView subclass and connect it to the passwordStrengthView outlet.

  • [optional] Add an UILabel and connect it to the hintLabel outlet.

  • Specify that you want to use the newly created nib file. You can do this in two ways:

    • Using RowDefaults: use this if you want to use only this custom GenericPasswordRow in your app.
     GenericPasswordRow.defaultRowInitializer = {
             $0.cellProvider = CellProvider<GenericPasswordCell>(nibName: "MyPasswordCell", bundle: nil)
         }
    • Or create a custom row subclassing _GenericPasswordRow:
     final class MyPasswordRow: _GenericPasswordRow, RowType {
         required init(tag: String?) {
             super.init(tag: tag)
             cellProvider = CellProvider<GenericPasswordCell>(nibName: "MyPasswordCell", bundle: nil)
         }
     }

Custom Strength View

If you are providing a custom nib file, you can also provide a custom subclass of PasswordStrengthView different from the DefaultPasswordStrengthView. You just need to implement the following methods:

class PasswordStrengthView: UIView {

    public func setPasswordValidator(validator: PasswordValidator) { }
    public func updateStrength(password password: String, animated: Bool = true) { }

}

Custom Password Validation

In order to provide a custom password validation you need to provide a conformance to the PasswordValidator protocol at the passwordValidator property of the GenericPasswordRow instance.

protocol PasswordValidator {

    var maxStrength: Double { get }
    func strengthForPassword(password: String) -> Double
    func hintForPassword(password: String) -> String?
    func isPasswordValid(password: String) -> Bool
    func colorsForStrengths() -> [Double: UIColor]

}

This validator should define the strength of any given password between zero and maxStrength values. Also, the func colorsForStrengths() -> [Double: UIColor] function should return a dictionary specifying key points of strength values and the associated color starting from there. See DefaultPasswordValidator.

Author

What is on the roadmap?

What could be added to GenericPasswordRow:

  • Implement some Eureka Validation
  • Provide additional subclasses of PasswordStrengthView

Change Log

This can be found in the CHANGELOG.md file.

Comments
  • CocoaPods could not find compatible versions for pod

    CocoaPods could not find compatible versions for pod "Eureka"

    Hello,

    I wanted to integrate GenericPasswordRow to my project, but cocoapods displays this message :

    `[!] CocoaPods could not find compatible versions for pod "Eureka": In snapshot (Podfile.lock): Eureka (= 5.2.1, ~> 5.0)

    In Podfile: Eureka

    GenericPasswordRow was resolved to 1.0.0, which depends on
      Eureka (~> 1.7)
    

    `

    Could you please update the project to the latest Eureka framework version 5.2.1 please ?

    I cannot update myself, because I'm a beginner.

    Thank you in advance.

    opened by Kracter56 7
  • inherit from fieldcell and make nicer appearance in a list of cells

    inherit from fieldcell and make nicer appearance in a list of cells

    Hello! Thank you for this library, it is the only custom eureka cell I use and is a great one.

    I made this pull request to improve the row's behaviour in the context of a multi-row form. Inheriting from _FieldCell and KeyboardReturnHandler means the keyboard will have Next and Return on the keyboard with the expected "Eureka Standard" actions. It also gives the same TextFieldDelegate methods as all the other FieldCells so that the behaviour around text entry should be the same.

    I also modified the constraints of the cell: -changed the TextField's leading edge to 22 (from 10, aligns with other Eureka Text rows) -changed the password strength indicators leading edge to 10 (instead of match the TextField).

    Thanks again, Konrad

    opened by kradical 7
  • How to fetch real password before revealing it?

    How to fetch real password before revealing it?

    What's the best practice to do it?

    I found that I have to write a subclass MyGenericPasswordCell of GenericPasswordCell and override the togglePasswordVisibility method. After that, I have to write a MyGenericPasswordRow, _GenericPasswordRow. The Eureka framework is not friendly to add new row type.

    Actually, I just make visibilityButton public, and replace the target action.

    opened by everwanna 6
  • Bug: Infinite loop blocking main thread when password fills the width of the label.

    Bug: Infinite loop blocking main thread when password fills the width of the label.

    The title is pretty descriptive, but the issue is pretty easy to reproduce, just create a GenericPasswordRow with a customized password validator. When you try to type the password and it's long enough to fill the width of the field, main thread gets stuck, see traceback and screenshots below:

    Form:

    <<< GenericPasswordRow("user_password"){
      row in
      row.passwordValidator = CustomPasswordValidator()
      row.placeholder = NSLocalizedString("Password", comment: "Password")
      let passwordValidation = RuleClosure<String> { rowValue in
        return ((rowValue == nil) || !(self.form.values()["user_mail"] as? String == rowValue.value)) ? ValidationError(msg: NSLocalizedString("Wrong Password", comment: "Wrong Password Mail")) : nil
      }
      row.add(rule: passwordValidation)
    }
    

    Validator:

    class CustomPasswordValidator: PasswordValidator {
        
        fileprivate struct PasswordRule {
            
            let hint: String
            let test: (String) -> Bool
        }
        
        open let maxStrength = 5.0
        
        fileprivate let rules: [PasswordRule] = [
            PasswordRule(hint: "Please enter a lowercase letter") { $0.satisfiesRegexp("[a-z]") },
            PasswordRule(hint: "Please enter a number or a special character") { $0.satisfiesRegexp("(?=.*([0-9]|[^\\w]))") },
            PasswordRule(hint: "Please enter an uppercase letter") { $0.satisfiesRegexp("[A-Z]") },
            PasswordRule(hint: "At least 8 characters") { $0.characters.count > 7 },
            PasswordRule(hint: "No more than two consecutive repeating characters or numbers") { $0.satisfiesRegexp("^(?!.*(.)\\1{1})") }
            
        ]
        
        internal func strengthForPassword(_ password: String) -> Double {
            return rules.reduce(0) { $0 + ($1.test(password) ? 1 : 0) }
        }
        
        internal func hintForPassword(_ password: String) -> String? {
            return rules.reduce([]) { $0 + ($1.test(password) ? []: [$1.hint]) }.first
        }
        
        internal func isPasswordValid(_ password: String) -> Bool {
            return rules.reduce(true) { $0 && $1.test(password) }
        }
        
        internal func colorsForStrengths() -> [Double: UIColor] {
            return [
                0: UIColor(red: 244 / 255, green: 67 / 255, blue: 54 / 255, alpha: 1),
                1: UIColor(red: 255 / 255, green: 193 / 255, blue: 7 / 255, alpha: 1),
                2: UIColor(red: 3 / 255, green: 169 / 255, blue: 244 / 255, alpha: 1),
                3: UIColor(red: 153 / 255, green: 255 / 255, blue: 153 / 255, alpha: 1),
                4: UIColor(red: 139 / 255, green: 195 / 255, blue: 74 / 255, alpha: 1)
            ]
        }
        
    }
    
    extension String {
        
        func satisfiesRegexp(_ regexp: String) -> Bool {
            return range(of: regexp, options: .regularExpression) != nil
        }
        
    }
    
    

    Main Thread Stack: MainThreadStack

    Stuck at: Here!

    P.D.: Commenting out both beginUpdates() and endUpdates() do not fix the issue, getting stuck at an unknown traceable point of execution.

    EDIT: It seems that something that I can't properly debug allocates (after 30 seconds of blocking the Main Thread as I described) up to 1GB of RAM before getting: Message from debugger: Terminated due to memory issue

    opened by minuscorp 5
  • Swift 3 support

    Swift 3 support

    Change log:

    • Updated code to match API and style changes.
    • Updated eureka to version 2.0.0-beta.1 for swift 3 support.
    • Implemented initWithCoder, now is needed.
    opened by mcousillas6 4
  • How to let Eureka trigger onChange() event on my custom Row?

    How to let Eureka trigger onChange() event on my custom Row?

    Hello everyone ;)

    I post the Q in stack stackoverflow at here :

    https://stackoverflow.com/questions/48866055/how-to-let-eureka-trigger-onchange-event-on-my-custom-row

    Can anyone help me??? Thanks a lot.

    Q details:

    I write a custom Row , and Row's value is this :

    struct CountUnit:Equatable,InputTypeInitiable{
    
        var totalCount:Int
        var unit:String
    
        init?(string stringValue: String) {
            //...
        }
    
        static func ==(lhs: CountUnit, rhs: CountUnit) -> Bool {
            //...
        }
    }
    

    What I ask is that : How to let Eureka invoke onChange() event on any of CountUnit's instance value changed???(totalCount and unit) :

    <<< CountUnitRow() {row in
        //do some init...
    }.onChange {row in
        //how to let user know value was changed
    }
    

    Thanks a lot ;)

    opened by hopy11 1
  • How to use Eureka Cell behavior by inherit from _FieldCell in my custom Cell class

    How to use Eureka Cell behavior by inherit from _FieldCell in my custom Cell class

    Hello guys :)

    I notice that GenericPasswordCell inherit from _FieldCell,to take advantage of keyboard handle(eg: automatic keyboard‘s expand/collapse and return button with Eureka)

    I also notice in GenericPasswordCell.xib,The only textField instead of bind with GenericPasswordCell,it bind with textField in _FieldCell.How to do that???

    I try do the same (bind my textField to _FieldCell in IB),but can not be successful!

    2018-02-18 15 42 55

    How can I bind textField in my custom Cell to take advantage of keyboard handle from _FieldCell class???

    thanks a lot!

    opened by hopy11 1
  • Dark mode support

    Dark mode support

    Replaced custom white background color by Secondary system grouped background color so that this component supports dark mode with the same background color as the one used by other Eureka components

    opened by sarbogast 0
  • Swift 4.2 and Xcode 10.1 support

    Swift 4.2 and Xcode 10.1 support

    • Update project files to adopt new default configurations in Xcode 10.1
    • Update source to support Swift 4.2
    • Update Travis configuration to adopt Xcode 10.1
    opened by jimmyti 0
  • Changing background color

    Changing background color

    Hey, the standard way of changing the background color of the content cell does not work on PasswordRow.

    dark_quotes_xcworkspace

    .cellSetup { cell, row in cell.backgroundColor = .blue }

    opened by shi-rudo 4
  • Crashing on IOS 12

    Crashing on IOS 12

    I am getting this error on iOS 12:

    'Could not load NIB in bundle: 'NSBundle </var/containers/Bundle/Application/F0AAD157-7E76-4F0C-9ED2-336FDC1D0092/FamClub.app> (loaded)' with name 'GenericPasswordCell''

    It seems like something in this framweork has broken or is not supported in iOS 12.

    Anyone else experiencing this?

    opened by uknowmeright 3
Releases(3.1.0)
Owner
Eureka Community
Eureka ecosystem plugins and projects
Eureka Community
PhotoRow - Simple image row based on Eureka for iOS

PhotoRow Simple image row based on Eureka for iOS. Since source type photoLibrar

Objective_Charm 1 Jan 22, 2022
CodableCSV - Read and write CSV files row-by-row or through Swift's Codable interface.

CodableCSV provides: Imperative CSV reader/writer. Declarative CSV encoder/decoder. Support multiple inputs/outputs: Strings, Data blobs, URLs, and St

Marcos Sánchez-Dehesa 369 Jan 8, 2023
A custom TextField with a switchable icon which shows or hides the password and enforce good password policies

PasswordTextField A custom TextField with a switchable icon which shows or hides the password and enforces good password policies, written in Swift. ⭐

Chris Jimenez 304 Dec 29, 2022
SwiftCop is a validation library fully written in Swift and inspired by the clarity of Ruby On Rails Active Record validations.

SwiftCop is a validation library fully written in Swift and inspired by the clarity of Ruby On Rails Active Record validations. Objective Build a stan

Andres Canal 542 Sep 17, 2022
Add validations to your text fields, Group them together and navigate through them via keyboard's return button and accessory view.

TFManager Let's say you have multiple UITextFields to get data from users. You need to handle each field keyboard's return key and add an accessory vi

Hosein Abbaspour 16 Sep 29, 2022
Native and encrypted password manager for iOS and macOS.

Open Sesame Native and encrypted password manager for iOS and macOS. What is it? OpenSesame is a free and powerful password manager that lets you mana

OpenSesame 432 Jan 7, 2023
A panel component similar to the iOS Airpod battery panel or the Share Wi-Fi password panel.

A SwiftUI panel component similar to the iOS Airpod battery panel or the Share Wi-Fi password panel.

Red Davis 12 Feb 7, 2022
Native and encrypted password manager for iOS and macOS.

Open Sesame Native and encrypted password manager for iOS and macOS. What is it? OpenSesame is a free and powerful password manager that lets you mana

OpenSesame 431 Dec 28, 2022
Simple command line to generate random password.

pwgen Simple command line to generate random password. ➜ Bootstrap pwgen n5aR[[email protected]@fj ➜ Bootstrap pwgen 32 f0)th54[wpX.Zf99nj

Lakr Aream 2 Dec 19, 2022
Private Password Manager developped with Swift for iOS project.

Private Password Manager developped with Swift for iOS project. This manager can syncronize secret data to Azure Blob Storage. To specify user account, tSecret use Azure Active Directory authentication.

Manabu Tonosaki 0 Dec 3, 2021
A realistic password strength estimator.

.................................................bbb.................... .zzzzzzzzzz..xxx....xxx....cccccccc..vvv....vvv..bbb.........nnnnnnn.... ....

Dropbox 219 Sep 21, 2022
Secure Remote Password SRP-6a implementation by swift

Thinbus-SRP Example To run the example project, clone the repo, and run pod install from the Example directory first. Requirements Installation Thinbu

null 1 Dec 20, 2021
Password generator and strength tester

Password-Generator Password generator and strength tester Description This was a

null 5 Feb 1, 2022
A KeePass/Password Safe Client for iOS and OS X

Strongbox A Personal Password Manager for iOS & OSX that can be found on the Apple App Store here: https://apps.apple.com/app/strongbox-password-safe/

Strongbox 976 Jan 3, 2023
A native, lightweight and secure time-based (TOTP) & counter-based (HOTP) password client built for iOS

A native, lightweight and secure time-based (TOTP) & counter-based (HOTP) password client built for iOS Built by Tijme Gommers – Buy me a coffee via P

Raivo OTP 770 Jan 8, 2023
PassDrop is a fully-featured secure password management system, compatible with the free KeePass 1.x (Classic) and multi-platform KeePassX desktop applications.

passdrop This is a modern, updated build of Rudis Muiznieks's PassDrop application. PassDrop is a fully-featured secure password management system, co

Chad Austin 33 Sep 23, 2022
Simple, secure password and data management for individuals and teams

Padloc Simple, secure password and data management for individuals and teams (formerly known as Padlock). This repo is split into multiple packages: P

Padloc 2.1k Jan 8, 2023
MiniKeePass provides secure password storage on your phone that's compatible with KeePass.

MiniKeePass MiniKeePass provides secure password storage on your phone that's compatible with KeePass. View, Edit, and Create KeePass 1.x and 2.x file

null 896 Dec 14, 2022
KeePassium is a KeePass-compatible password manager for iOS

KeePassium is a KeePass-compatible password manager for iOS. It offers automatic database synchronization, respect to privacy and premium user experience.

KeePassium 839 Jan 8, 2023
FreeOTP is a two-factor authentication application for systems utilizing one-time password protocols

FreeOTP FreeOTP is a two-factor authentication application for systems utilizing one-time password protocols. Tokens can be added easily by scanning a

FreeOTP 551 Dec 28, 2022