Numerous cleanups to the DiscussionBoard example. Need to finish working through cleanups to the authentication process and polish off documentation. Should be ready for merge tomorrow night.

This commit is contained in:
Blake Watters
2011-01-18 23:25:19 -05:00
parent 7e2f49e814
commit 8f863b4c50
18 changed files with 305 additions and 114 deletions

View File

@@ -9,12 +9,23 @@
#import <RestKit/RestKit.h>
#import <RestKit/CoreData/CoreData.h>
@interface DBUser : RKManagedObject {
// Declared here and defined below
@protocol DBUserDelegate;
////////////////////////////////////////////////////////////////////////////////////////////////
@interface DBUser : RKManagedObject <RKObjectLoaderDelegate> {
// Transient. Used for login & sign-up
NSString* _password;
NSString* _passwordConfirmation;
NSObject<DBUserDelegate>* _delegate;
}
/**
* The delegate for the User. Will be informed of session life-cycle events
*/
@property (nonatomic, retain) NSObject<DBUserDelegate>* delegate;
/**
* The e-mail address of the User
*/
@@ -23,14 +34,11 @@
/**
* The username of the User
*/
// TODO: Inconsistencies between username & login
@property (nonatomic, retain) NSString* login;
@property (nonatomic, retain) NSString* username;
// Access Token will only be populated on a logged in user.
/**
* An Access Token returned when a User is authenticated
*/
// TODO: Check design on this
@property (nonatomic, retain) NSString* singleAccessToken;
/**
@@ -50,13 +58,60 @@
*/
@property (nonatomic, retain) NSString* passwordConfirmation;
////////////////////////////////////////////////////////////////////////////////////////////////
/**
* A globally available singleton reference to the current User
* A globally available singleton reference to the current User. When the User is
* not authenticated, a new object will be constructed and returned
*/
+ (DBUser*)currentUser;
// TODO: Change to an instance method...
+ (void)logout;
/**
* Attempts to log a User into the system with a given username and password
*/
- (void)loginWithUsername:(NSString*)username andPassword:(NSString*)password;
/**
* Returns YES when the User is logged in
*/
- (BOOL)isLoggedIn;
/**
* Logs the User out of the system
*/
- (void)logout;
@end
////////////////////////////////////////////////////////////////////////////////////////////////
////////////////////////////////////////////////////////////////////////////////////////////////
/**
* Notifications
*/
extern NSString* const DBUserDidLoginNotification; // Posted when the User logs in
extern NSString* const DBUserDidFailLoginNotification; // Posted when the User fails login. userInfo contains NSError with reason
extern NSString* const DBUserDidLogoutNotification; // Posted when the User logs out
/**
* A protocol defining life-cycles events for a user logging in and out
* of the application
*/
@protocol DBUserDelegate
/**
* Sent to the delegate when the User has successfully authenticated
*/
- (void)userDidLogin:(DBUser*)user;
/**
* Sent to the delegate when the User failed login for a specific reason
*/
- (void)user:(DBUser*)user didFailLoginWithError:(NSError*)error;
/**
* Sent to the delegate when the User logged out of the system
*/
- (void)userDidLogout:(DBUser*)user;
@end