mirror of
https://github.com/vector-im/element-ios.git
synced 2024-09-28 23:32:41 +00:00
IM: Detect not signed terms error
(cherry picked from commit 80877eabaf
)
This commit is contained in:
parent
21388e22de
commit
0f8db40c98
2 changed files with 25 additions and 2 deletions
|
@ -56,10 +56,12 @@ typedef enum : NSUInteger
|
|||
WidgetManagerErrorCodeNotEnoughPower,
|
||||
WidgetManagerErrorCodeCreationFailed,
|
||||
WidgetManagerErrorCodeNoIntegrationsServerConfigured,
|
||||
WidgetManagerErrorCodeFailedToConnectToIntegrationsServer
|
||||
WidgetManagerErrorCodeFailedToConnectToIntegrationsServer,
|
||||
WidgetManagerErrorCodeTermsNotSigned
|
||||
}
|
||||
WidgetManagerErrorCode;
|
||||
|
||||
FOUNDATION_EXPORT NSString *const WidgetManagerErrorOpenIdTokenKey;
|
||||
|
||||
/**
|
||||
The `WidgetManager` helps to handle modular widgets.
|
||||
|
|
|
@ -513,6 +513,8 @@ NSString *const WidgetManagerErrorDomain = @"WidgetManagerErrorDomain";
|
|||
MXHTTPOperation *operation;
|
||||
NSString *userId = mxSession.myUser.userId;
|
||||
|
||||
NSLog(@"[WidgetManager] registerForScalarToken");
|
||||
|
||||
WidgetManagerConfig *config = [self configForUser:userId];
|
||||
if (!config.hasUrls)
|
||||
{
|
||||
|
@ -539,6 +541,10 @@ NSString *const WidgetManagerErrorDomain = @"WidgetManagerErrorDomain";
|
|||
MXJSONModelSetString(scalarToken, JSONResponse[@"scalar_token"])
|
||||
config.scalarToken = scalarToken;
|
||||
|
||||
// Validate it (this mostly checks to see if the IM needs us to agree to some terms)
|
||||
// TODO
|
||||
// return this._checkToken(tokenObject);
|
||||
|
||||
self->configs[userId] = config;
|
||||
[self saveConfigs];
|
||||
|
||||
|
@ -622,7 +628,22 @@ NSString *const WidgetManagerErrorDomain = @"WidgetManagerErrorDomain";
|
|||
}
|
||||
else if (failure)
|
||||
{
|
||||
failure(error);
|
||||
MXError *mxError = [[MXError alloc] initWithNSError:error];
|
||||
if ([mxError.errcode isEqualToString:kMXErrCodeStringTermsNotSigned])
|
||||
{
|
||||
NSLog(@"[WidgetManager] validateScalarToke. Error: Need to accept terms");
|
||||
NSError *termsNotSignedError = [NSError errorWithDomain:WidgetManagerErrorDomain
|
||||
code:WidgetManagerErrorCodeTermsNotSigned
|
||||
userInfo:@{
|
||||
NSLocalizedDescriptionKey:error.userInfo[NSLocalizedDescriptionKey]
|
||||
}];
|
||||
|
||||
failure(termsNotSignedError);
|
||||
}
|
||||
else
|
||||
{
|
||||
failure(error);
|
||||
}
|
||||
}
|
||||
}];
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue