-
Notifications
You must be signed in to change notification settings - Fork 43
/
SPAuthenticator.h
69 lines (48 loc) · 2.21 KB
/
SPAuthenticator.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
//
// SPAuthenticator.h
// Simperium
//
// Created by Michael Johnston on 12-02-27.
// Copyright (c) 2012 Simperium. All rights reserved.
//
#import <Foundation/Foundation.h>
typedef void(^SuccessBlockType)(void);
typedef void(^FailureBlockType)(NSInteger responseCode, NSString * _Nullable responseString, NSError * _Nullable error);
@class Simperium;
NS_ASSUME_NONNULL_BEGIN
#pragma mark ====================================================================================
#pragma mark SPAuthenticatorDelegate
#pragma mark ====================================================================================
@protocol SPAuthenticatorDelegate <NSObject>
@optional
- (void)authenticationDidSucceedForUsername:(NSString *)username token:(NSString *)token;
- (void)authenticationDidCreateAccount;
- (void)authenticationDidFail;
- (void)authenticationDidCancel;
@end
#pragma mark ====================================================================================
#pragma mark SPAuthenticator
#pragma mark ====================================================================================
@interface SPAuthenticator : NSObject
@property (nonatomic, copy, readwrite) NSString *providerString;
@property (nonatomic, assign, readonly) BOOL connected;
- (instancetype)initWithDelegate:(id<SPAuthenticatorDelegate>)authDelegate simperium:(Simperium *)s;
- (BOOL)authenticateIfNecessary;
- (void)authenticateWithUsername:(NSString *)username
token:(NSString *)token;
- (void)authenticateWithUsername:(NSString *)username
password:(NSString *)password
success:(SuccessBlockType)successHandler
failure:(FailureBlockType)failureHandler;
- (void)validateWithUsername:(NSString *)username
password:(NSString *)password
success:(SuccessBlockType)successHandler
failure:(FailureBlockType)failureHandler;
- (void)signupWithUsername:(NSString *)username
password:(NSString *)password
success:(SuccessBlockType)successHandler
failure:(FailureBlockType)failureHandler;
- (void)reset;
- (void)cancel;
@end
NS_ASSUME_NONNULL_END