Skip to content
This repository has been archived by the owner on Aug 25, 2023. It is now read-only.

Commit

Permalink
Merge branch 'voximplant-sdk-2.38.0'
Browse files Browse the repository at this point in the history
  • Loading branch information
VladimirBrejcha committed Apr 27, 2021
2 parents 3a70c35 + 299bc64 commit 484c1b1
Show file tree
Hide file tree
Showing 18 changed files with 162 additions and 837 deletions.
88 changes: 45 additions & 43 deletions AudioCall/ACAuthService.m
Original file line number Diff line number Diff line change
Expand Up @@ -86,29 +86,31 @@ - (void)loginWithUser:(NSString *)user
__strong ACAuthService *strongSelf = weakSelf;
[strongSelf.client loginWithUser:user
password:password
success:^(NSString * _Nonnull userDisplayName, VIAuthParams * _Nonnull authParams) {
NSTimeInterval refreshExpire = authParams.refreshExpire;
NSString *refreshToken = authParams.refreshToken;
NSTimeInterval accessExpire = authParams.accessExpire;
NSString *accessToken = authParams.accessToken;

__strong ACAuthService *strongSelf = weakSelf;

VoxToken *validAccessToken = [VoxToken createToken:accessToken
expireDate:[NSDate dateWithTimeIntervalSinceNow:accessExpire]];

VoxToken *validRefreshToken = [VoxToken createToken:refreshToken
expireDate:[NSDate dateWithTimeIntervalSinceNow:refreshExpire]];
VoxKeys *keys = [VoxKeys keyholderWithAccess:validAccessToken refresh:validRefreshToken];
[strongSelf.tokenManager setKeys:keys];
strongSelf.loggedInUser = user;
strongSelf.loggedInUserDisplayName = userDisplayName;

completion(userDisplayName, nil);
}
success:^(NSString *_Nonnull userDisplayName, VIAuthParams *_Nullable authParams) {
__strong ACAuthService *strongSelf = weakSelf;
if (authParams) {
NSTimeInterval refreshExpire = authParams.refreshExpire;
NSString *refreshToken = authParams.refreshToken;
NSTimeInterval accessExpire = authParams.accessExpire;
NSString *accessToken = authParams.accessToken;


VoxToken *validAccessToken = [VoxToken createToken:accessToken
expireDate:[NSDate dateWithTimeIntervalSinceNow:accessExpire]];

VoxToken *validRefreshToken = [VoxToken createToken:refreshToken
expireDate:[NSDate dateWithTimeIntervalSinceNow:refreshExpire]];
VoxKeys *keys = [VoxKeys keyholderWithAccess:validAccessToken refresh:validRefreshToken];
[strongSelf.tokenManager setKeys:keys];
}
strongSelf.loggedInUser = user;
strongSelf.loggedInUserDisplayName = userDisplayName;

completion(userDisplayName, nil);
}
failure:^(NSError * _Nonnull error) {
completion(nil, error);
}];
completion(nil, error);
}];
}];
}];
}
Expand Down Expand Up @@ -152,27 +154,27 @@ - (void)loginUsingTokenWithCompletion:(VoxResult)completion {
__strong ACAuthService *strongSelf = weakSelf;
[strongSelf.client loginWithUser:user
token:accessToken.token
success:^(NSString * _Nonnull userDisplayName, VIAuthParams * _Nonnull authParams) {
NSTimeInterval refreshExpire = authParams.refreshExpire;
NSString *refreshToken = authParams.refreshToken;
NSTimeInterval accessExpire = authParams.accessExpire;
NSString *accessToken = authParams.accessToken;
if (refreshExpire && refreshToken && accessExpire && accessToken) {
VoxToken *validAccessToken = [VoxToken createToken:accessToken
expireDate:[NSDate dateWithTimeIntervalSinceNow:accessExpire]];
VoxToken *validRefreshToken = [VoxToken createToken:refreshToken
expireDate:[NSDate dateWithTimeIntervalSinceNow:refreshExpire]];
VoxKeys *keys = [VoxKeys keyholderWithAccess:validAccessToken refresh:validRefreshToken];
[strongSelf.tokenManager setKeys:keys];
strongSelf.loggedInUser = user;
strongSelf.loggedInUserDisplayName = userDisplayName;
}
completion(userDisplayName, nil);
} failure:^(NSError * _Nonnull error) {
completion(nil, error);
}];
success:^(NSString * _Nonnull userDisplayName, VIAuthParams *_Nullable authParams) {
__strong ACAuthService *strongSelf = weakSelf;
if (authParams) {
NSTimeInterval refreshExpire = authParams.refreshExpire;
NSString *refreshToken = authParams.refreshToken;
NSTimeInterval accessExpire = authParams.accessExpire;
NSString *accessToken = authParams.accessToken;
VoxToken *validAccessToken = [VoxToken createToken:accessToken
expireDate:[NSDate dateWithTimeIntervalSinceNow:accessExpire]];
VoxToken *validRefreshToken = [VoxToken createToken:refreshToken
expireDate:[NSDate dateWithTimeIntervalSinceNow:refreshExpire]];
VoxKeys *keys = [VoxKeys keyholderWithAccess:validAccessToken refresh:validRefreshToken];
[strongSelf.tokenManager setKeys:keys];
}
strongSelf.loggedInUser = user;
strongSelf.loggedInUserDisplayName = userDisplayName;
completion(userDisplayName, nil);

} failure:^(NSError * _Nonnull error) {
completion(nil, error);
}];
}];
}];
}];
Expand Down
Loading

0 comments on commit 484c1b1

Please sign in to comment.