forked from chromium/chromium
-
Notifications
You must be signed in to change notification settings - Fork 0
/
remoting_authentication.h
54 lines (39 loc) · 1.94 KB
/
remoting_authentication.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
// Copyright 2017 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#ifndef REMOTING_IOS_FACADE_REMOTING_AUTHENTICATION_H_
#define REMOTING_IOS_FACADE_REMOTING_AUTHENTICATION_H_
#import "remoting/ios/domain/user_info.h"
#include "base/memory/weak_ptr.h"
typedef NS_ENUM(NSInteger, RemotingAuthenticationStatus) {
RemotingAuthenticationStatusSuccess,
RemotingAuthenticationStatusNetworkError,
RemotingAuthenticationStatusAuthError
};
typedef void (^AccessTokenCallback)(RemotingAuthenticationStatus status,
NSString* userEmail,
NSString* accessToken);
// |RemotingAuthenticationDelegate|s are interested in authentication related
// notifications.
@protocol RemotingAuthenticationDelegate<NSObject>
// Notifies the delegate that the user has been updated.
- (void)userDidUpdate:(UserInfo*)user;
@end
// This is the interface that will manage the details around authentication
// management and currently active user. It will make sure the user object is
// saved to the keychain correctly and loaded on startup. It also is the entry
// point for gaining access to an auth token for authrized calls.
@protocol RemotingAuthentication<NSObject>
// Fetches an Access Token and passes it back to the callback if the user is
// authenticated. Otherwise does nothing.
// TODO(nicholss): We might want to throw an error or add error message to
// the callback sig to be able to react to the un-authed case.
- (void)callbackWithAccessToken:(AccessTokenCallback)onAccessToken;
// Forget the current user.
- (void)logout;
// Returns the currently logged in user or nil.
@property(strong, nonatomic, readonly) UserInfo* user;
// Delegate recieves updates on user changes.
@property(weak, nonatomic) id<RemotingAuthenticationDelegate> delegate;
@end
#endif // REMOTING_IOS_FACADE_REMOTING_AUTHENTICATION_H_