Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feature hide SignUp & Reset Password buttons #122

Merged
merged 3 commits into from
May 22, 2015
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 1 addition & 2 deletions Lock/Podfile
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@ platform :ios, '8.0'
def pod_with_warnings
pod 'libextobjc', :inhibit_warnings => true #Ignore warnings for this lib
pod 'BDBOAuth1Manager', :inhibit_warnings => true #Ignore warnings for this lib
pod 'Facebook-iOS-SDK', :inhibit_warnings => true #Ignore warnings for this lib
pod 'ISO8601DateFormatter', :inhibit_warnings => true #Ignore warnings for this lib
end

Expand All @@ -15,7 +14,7 @@ target 'Lock', :exclusive => true do
pod 'Lock/SMS', :path => '../'
pod 'Lock/ReactiveCore', :path => '../'
pod 'Lock/1Password', :path => '../'
pod 'Lock-Facebook', '~> 1.0'
pod 'Lock-Facebook', '~> 2.0'
pod 'Lock-Twitter', '~> 1.0'
pod 'Lock-GooglePlus', '~> 1.0'

Expand Down
27 changes: 19 additions & 8 deletions Lock/Podfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -39,8 +39,17 @@ PODS:
- CocoaLumberjack/Extensions (2.0.0):
- CocoaLumberjack/Default
- Expecta (1.0.0)
- Facebook-iOS-SDK (3.23.2):
- Bolts (~> 1.0)
- FBSDKCoreKit (4.1.0):
- Bolts (~> 1.1)
- FBSDKCoreKit/arc (= 4.1.0)
- FBSDKCoreKit/no-arc (= 4.1.0)
- FBSDKCoreKit/arc (4.1.0):
- Bolts (~> 1.1)
- FBSDKCoreKit/no-arc (4.1.0):
- Bolts (~> 1.1)
- FBSDKCoreKit/arc
- FBSDKLoginKit (4.1.0):
- FBSDKCoreKit
- googleplus-ios-sdk (1.7.1)
- ISO8601DateFormatter (0.7)
- JWTDecode (0.2.1)
Expand Down Expand Up @@ -84,8 +93,10 @@ PODS:
- libextobjc (~> 0.4)
- Lock/Core (= 1.12.1)
- Lock/UI (= 1.12.1)
- Lock-Facebook (1.0.0):
- Facebook-iOS-SDK (~> 3.15)
- Lock-Facebook (2.0.1):
- CocoaLumberjack (~> 2.0)
- FBSDKCoreKit (~> 4.0)
- FBSDKLoginKit (~> 4.0)
- Lock/Core (~> 1.11)
- Lock-GooglePlus (1.0.1):
- googleplus-ios-sdk (~> 1.7.1)
Expand Down Expand Up @@ -152,12 +163,11 @@ PODS:
DEPENDENCIES:
- BDBOAuth1Manager
- Expecta
- Facebook-iOS-SDK
- ISO8601DateFormatter
- JWTDecode
- libextobjc
- Lock (from `../`)
- Lock-Facebook (~> 1.0)
- Lock-Facebook (~> 2.0)
- Lock-GooglePlus (~> 1.0)
- Lock-Twitter (~> 1.0)
- Lock/1Password (from `../`)
Expand All @@ -181,13 +191,14 @@ SPEC CHECKSUMS:
Bolts: aac24961496d504aa56fc267cde95162a71bac39
CocoaLumberjack: a6f77d987d65dc7ba86b0f84db7d0b9084f77bcb
Expecta: 32604574add2c46a36f8d2f716b6c5736eb75024
Facebook-iOS-SDK: cd87f0b2f0c1d9574b44e8fa2baacc275524bac3
FBSDKCoreKit: 469ed167195f860dbd2b4c4bbaa33d2e90598db9
FBSDKLoginKit: ff6224762732e3698f30942e4544321b8c7a23e6
googleplus-ios-sdk: 065d9135061a5f84c07656a68ced48336408fe35
ISO8601DateFormatter: ab926648eebe497f4d167c0fd083992f959f1274
JWTDecode: bff190dc06ff9ee7a3a244c454dc8ef05962c994
libextobjc: a650fc1bf489a3d3a9bc2e621efa3e1006fc5471
Lock: ea007a23242b55f95433b848f9223e297165739d
Lock-Facebook: fc83349f48dee2d41fe8a36013502fe64a0d77fc
Lock-Facebook: 02c315b7d15d6fed20c7a2ea8a5e5e27c072483a
Lock-GooglePlus: 38ea73da70d3dd3d210dfb7716b5aeed5aaabca6
Lock-Twitter: 61168e95f6614535167621794cbada2d6606d4c5
LUKeychainAccess: 6479edb12cf06e11ff3336f796959eedbc58f714
Expand Down
5 changes: 4 additions & 1 deletion Lock/Tests/A0IdentityProviderAuthenticatorSpec.m
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@
#import "A0Strategy.h"
#import "A0Errors.h"
#import "A0WebAuthenticator.h"
#import "A0Lock.h"

#define HC_SHORTHAND
#import <OCHamcrest/OCHamcrest.h>
Expand All @@ -48,9 +49,11 @@ @interface A0IdentityProviderAuthenticator (TestAPI)
describe(@"A0SocialAuthenticator", ^{

__block A0IdentityProviderAuthenticator *authenticator;
__block A0Lock *lock;

beforeEach(^{
authenticator = [[A0IdentityProviderAuthenticator alloc] init];
lock = mock(A0Lock.class);
authenticator = [[A0IdentityProviderAuthenticator alloc] initWithLock:lock];
});

describe(@"provider registration", ^{
Expand Down
61 changes: 61 additions & 0 deletions Lock/Tests/A0LockConfigurationSpec.m
Original file line number Diff line number Diff line change
Expand Up @@ -244,6 +244,67 @@
});

});

describe(@"disable Sign Up & Reset Password", ^{

__block A0LockConfiguration *configuration;

before(^{
NSData *jsonData = [NSData dataWithContentsOfFile:[[NSBundle bundleForClass:self.class] pathForResource:@"AppInfo" ofType:@"json"]];
NSDictionary *json = [NSJSONSerialization JSONObjectWithData:jsonData options:0 error:nil];
application = [[A0Application alloc] initWithJSONDictionary:json];
configuration = [[A0LockConfiguration alloc] initWithApplication:application filter:@[]];
});

context(@"when enabled in connection", ^{

beforeEach(^{
configuration.defaultDatabaseConnectionName = @"Username-PasswordAuthentication";
});

it(@"should disable Sign Up", ^{
expect([configuration shouldDisableSignUp:YES]).to.beTruthy();
});

it(@"should not disable Sign Up", ^{
expect([configuration shouldDisableSignUp:NO]).to.beFalsy();
});

it(@"should disable Reset Password", ^{
expect([configuration shouldDisableResetPassword:YES]).to.beTruthy();
});

it(@"should not disable Reset Password", ^{
expect([configuration shouldDisableResetPassword:NO]).to.beFalsy();
});

});

context(@"when disabled in connection", ^{

beforeEach(^{
configuration.defaultDatabaseConnectionName = @"LoginOnly";
});

it(@"should disable Sign Up", ^{
expect([configuration shouldDisableSignUp:YES]).to.beTruthy();
});

it(@"should not disable Sign Up", ^{
expect([configuration shouldDisableSignUp:NO]).to.beTruthy();
});

it(@"should disable Reset Password", ^{
expect([configuration shouldDisableResetPassword:YES]).to.beTruthy();
});

it(@"should not disable Reset Password", ^{
expect([configuration shouldDisableResetPassword:NO]).to.beTruthy();
});

});

});
});

SpecEnd
7 changes: 7 additions & 0 deletions Lock/Tests/AppInfo.json
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,13 @@
"showSignup": true,
"showForgot": true,
"requires_username": false
}, {
"name": "LoginOnly",
"forgot_password_url": "https://login.auth0.com/lo/forgot?wtrealm=urn:auth0:samples:LoginOnly",
"signup_url": "https://login.auth0.com/lo/signup?wtrealm=urn:auth0:samples:LoginOnly",
"showSignup": false,
"showForgot": false,
"requires_username": false
}]
}, {
"name": "ad",
Expand Down
4 changes: 2 additions & 2 deletions Pod/Assets/TouchID/A0TouchIDRegisterViewController.xib
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<document type="com.apple.InterfaceBuilder3.CocoaTouch.XIB" version="3.0" toolsVersion="6751" systemVersion="14C1510" targetRuntime="iOS.CocoaTouch" propertyAccessControl="none" useAutolayout="YES" useTraitCollections="YES">
<document type="com.apple.InterfaceBuilder3.CocoaTouch.XIB" version="3.0" toolsVersion="7706" systemVersion="14D136" targetRuntime="iOS.CocoaTouch" propertyAccessControl="none" useAutolayout="YES" useTraitCollections="YES">
<dependencies>
<plugIn identifier="com.apple.InterfaceBuilder.IBCocoaTouchPlugin" version="6751"/>
<plugIn identifier="com.apple.InterfaceBuilder.IBCocoaTouchPlugin" version="7706"/>
</dependencies>
<objects>
<placeholder placeholderIdentifier="IBFilesOwner" id="-1" userLabel="File's Owner" customClass="A0TouchIDRegisterViewController">
Expand Down
15 changes: 4 additions & 11 deletions Pod/Classes/Provider/A0IdentityProviderAuthenticator.m
Original file line number Diff line number Diff line change
Expand Up @@ -49,24 +49,17 @@ + (A0IdentityProviderAuthenticator *)sharedInstance {
}

- (instancetype)initWithLock:(A0Lock *)lock {
#pragma GCC diagnostic push
#pragma GCC diagnostic ignored "-Wdeprecated"
self = [self init];
#pragma GCC diagnostic pop
self = [super init];
if (self) {
_registeredAuthenticators = [@{} mutableCopy];
_useWebAsDefault = YES;
_clientProvider = lock;
}
return self;
}

- (id)init {
self = [super init];
if (self) {
_registeredAuthenticators = [@{} mutableCopy];
_useWebAsDefault = YES;
_clientProvider = nil;
}
return self;
return [self initWithLock:nil];
}

- (void)registerAuthenticationProviders:(NSArray *)authenticationProviders {
Expand Down
2 changes: 0 additions & 2 deletions Pod/Classes/TouchID/A0TouchIDRegisterViewController.m
Original file line number Diff line number Diff line change
Expand Up @@ -76,8 +76,6 @@ - (void)viewDidLoad {
- (A0DatabaseLoginViewController *)buildLogin {
@weakify(self);
A0DatabaseLoginViewController *controller = [[A0DatabaseLoginViewController alloc] init];
controller.showSignUp = YES;
controller.showResetPassword = YES;
controller.parameters = self.parameters;
controller.onLoginBlock = self.onRegisterBlock;
controller.lock = self.lock;
Expand Down
4 changes: 4 additions & 0 deletions Pod/Classes/UI/A0LockConfiguration.h
Original file line number Diff line number Diff line change
Expand Up @@ -42,4 +42,8 @@

- (A0Connection *)defaultActiveDirectoryConnection;

- (BOOL)shouldDisableSignUp:(BOOL)disableSignUp;

- (BOOL)shouldDisableResetPassword:(BOOL)disableResetPassword;

@end
11 changes: 11 additions & 0 deletions Pod/Classes/UI/A0LockConfiguration.m
Original file line number Diff line number Diff line change
Expand Up @@ -111,4 +111,15 @@ - (NSArray *)selectFromArray:(NSArray *)array passingTest:(BOOL(^)(id element))t
}];
return [NSArray arrayWithArray:result];
}

- (BOOL)shouldDisableSignUp:(BOOL)disableSignUp {
A0Connection *database = self.defaultDatabaseConnection;
return ![database[A0ConnectionShowSignUp] boolValue] || disableSignUp;
}

- (BOOL)shouldDisableResetPassword:(BOOL)disableResetPassword {
A0Connection *database = self.defaultDatabaseConnection;
return ![database[A0ConnectionShowForgot] boolValue] || disableResetPassword;
}

@end
36 changes: 31 additions & 5 deletions Pod/Classes/UI/A0LockViewController.h
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,10 @@ typedef void(^A0AuthenticationBlock)(A0UserProfile *profile, A0Token *token);
*/
- (instancetype)init __attribute__((deprecated));

///------------------------------------------------
/// @name Callbacks
///------------------------------------------------

/**
Block that is called on successful authentication. It has two parameters profile and token, which will be non-nil unless login is disabled after signup.
*/
Expand All @@ -61,6 +65,10 @@ typedef void(^A0AuthenticationBlock)(A0UserProfile *profile, A0Token *token);
*/
@property (copy, nonatomic) void(^onUserDismissBlock)();

///------------------------------------------------
/// @name UI customization
///------------------------------------------------

/**
Enable the username to be treated as an email (and validated as one too) in all Auth0 screens. Default is YES
*/
Expand All @@ -71,6 +79,25 @@ typedef void(^A0AuthenticationBlock)(A0UserProfile *profile, A0Token *token);
*/
@property (assign, nonatomic) BOOL closable;

/**
View that will appear in the bottom of Signup screen. It should be used to show Terms & Conditions of your app.
*/
@property (strong, nonatomic) UIView *signUpDisclaimerView;

/**
* Hides the Sign Up button. By default is `false`.
*/
@property (assign, nonatomic) BOOL disableSignUp;

/**
* Hides the Reset Password button. By default is `false`.
*/
@property (assign, nonatomic) BOOL disableResetPassword;

///------------------------------------------------
/// @name Authentication options
///------------------------------------------------

/**
After a successful Signup, `A0AuthenticationViewController` will attempt to login the user if this property is YES otherwise will call onAuthenticationBlock with both parameters nil. Default value is YES
*/
Expand All @@ -83,11 +110,6 @@ typedef void(^A0AuthenticationBlock)(A0UserProfile *profile, A0Token *token);
*/
@property (assign, nonatomic) BOOL defaultADUsernameFromEmailPrefix;

/**
View that will appear in the bottom of Signup screen. It should be used to show Terms & Conditions of your app.
*/
@property (strong, nonatomic) UIView *signUpDisclaimerView;

/**
* When authenticating with a social connection, it will use an embedded webView instead of Safari. Default is NO.
*/
Expand All @@ -99,6 +121,10 @@ typedef void(^A0AuthenticationBlock)(A0UserProfile *profile, A0Token *token);
*/
@property (strong, nonatomic) A0AuthParameters *authenticationParameters;

///------------------------------------------------
/// @name Connection filtering
///------------------------------------------------

/**
* List of connections to be used by Lock.
* It can be used to filter connections already enabled in Auth0 dashboard. If a connection is not enabled in the dashboard it will be ignored.
Expand Down
Loading