2014-10-08 12:14:12 +00:00
|
|
|
/*
|
2015-04-14 08:55:18 +00:00
|
|
|
Copyright 2015 OpenMarket Ltd
|
2017-03-01 10:43:08 +00:00
|
|
|
Copyright 2017 Vector Creations Ltd
|
2019-07-23 09:51:46 +00:00
|
|
|
Copyright 2019 New Vector Ltd
|
|
|
|
|
2014-10-08 12:14:12 +00:00
|
|
|
Licensed under the Apache License, Version 2.0 (the "License");
|
|
|
|
you may not use this file except in compliance with the License.
|
|
|
|
You may obtain a copy of the License at
|
|
|
|
|
|
|
|
http://www.apache.org/licenses/LICENSE-2.0
|
|
|
|
|
|
|
|
Unless required by applicable law or agreed to in writing, software
|
|
|
|
distributed under the License is distributed on an "AS IS" BASIS,
|
|
|
|
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
|
|
See the License for the specific language governing permissions and
|
|
|
|
limitations under the License.
|
|
|
|
*/
|
|
|
|
|
2015-02-05 10:43:06 +00:00
|
|
|
#import "AuthenticationViewController.h"
|
2014-10-08 12:14:12 +00:00
|
|
|
|
2021-10-26 15:42:33 +00:00
|
|
|
#import "GeneratedInterface-Swift.h"
|
2020-06-24 15:09:23 +00:00
|
|
|
#import "MXSession+Riot.h"
|
2016-06-03 15:29:34 +00:00
|
|
|
|
2016-03-29 13:35:37 +00:00
|
|
|
#import "AuthInputsView.h"
|
2016-05-03 13:54:05 +00:00
|
|
|
#import "ForgotPasswordInputsView.h"
|
2019-09-16 08:43:30 +00:00
|
|
|
#import "AuthFallBackViewController.h"
|
2015-09-28 08:23:33 +00:00
|
|
|
|
2020-12-17 16:39:33 +00:00
|
|
|
static const CGFloat kAuthInputContainerViewMinHeightConstraintConstant = 150.0;
|
|
|
|
|
|
|
|
@interface AuthenticationViewController () <AuthFallBackViewControllerDelegate, KeyVerificationCoordinatorBridgePresenterDelegate, SetPinCoordinatorBridgePresenterDelegate,
|
2020-12-18 17:31:04 +00:00
|
|
|
SocialLoginListViewDelegate,
|
|
|
|
SSOAuthenticationPresenterDelegate
|
2020-12-17 16:39:33 +00:00
|
|
|
>
|
2016-05-09 11:56:37 +00:00
|
|
|
{
|
2017-03-10 10:09:46 +00:00
|
|
|
/**
|
|
|
|
The default country code used to initialize the mobile phone number input.
|
|
|
|
*/
|
|
|
|
NSString *defaultCountryCode;
|
2017-07-21 09:28:17 +00:00
|
|
|
|
|
|
|
/**
|
2019-01-11 09:32:56 +00:00
|
|
|
Observe kThemeServiceDidChangeThemeNotification to handle user interface theme change.
|
2017-07-21 09:28:17 +00:00
|
|
|
*/
|
2019-01-11 09:32:56 +00:00
|
|
|
id kThemeServiceDidChangeThemeNotificationObserver;
|
2019-03-07 09:08:39 +00:00
|
|
|
|
2020-04-28 16:52:03 +00:00
|
|
|
/**
|
|
|
|
Observe AppDelegateUniversalLinkDidChangeNotification to handle universal link changes.
|
|
|
|
*/
|
|
|
|
id universalLinkDidChangeNotificationObserver;
|
|
|
|
|
2019-03-07 09:08:39 +00:00
|
|
|
/**
|
|
|
|
Server discovery.
|
|
|
|
*/
|
|
|
|
MXAutoDiscovery *autoDiscovery;
|
2019-09-16 08:43:30 +00:00
|
|
|
|
|
|
|
AuthFallBackViewController *authFallBackViewController;
|
2020-07-17 16:03:00 +00:00
|
|
|
|
|
|
|
// successful login credentials
|
|
|
|
MXCredentials *loginCredentials;
|
2020-09-14 19:06:12 +00:00
|
|
|
|
|
|
|
// Check false display of this screen only once
|
|
|
|
BOOL didCheckFalseAuthScreenDisplay;
|
2016-05-09 11:56:37 +00:00
|
|
|
}
|
|
|
|
|
2019-08-14 12:11:06 +00:00
|
|
|
@property (nonatomic, readonly) BOOL isIdentityServerConfigured;
|
2020-04-03 14:30:06 +00:00
|
|
|
@property (nonatomic, strong) KeyVerificationCoordinatorBridgePresenter *keyVerificationCoordinatorBridgePresenter;
|
2020-07-17 16:03:00 +00:00
|
|
|
@property (nonatomic, strong) SetPinCoordinatorBridgePresenter *setPinCoordinatorBridgePresenter;
|
2020-08-04 14:01:26 +00:00
|
|
|
@property (nonatomic, strong) KeyboardAvoider *keyboardAvoider;
|
2019-08-14 12:11:06 +00:00
|
|
|
|
2020-12-17 16:39:33 +00:00
|
|
|
@property (weak, nonatomic) IBOutlet UIView *socialLoginContainerView;
|
|
|
|
@property (nonatomic, weak) SocialLoginListView *socialLoginListView;
|
|
|
|
|
2020-12-18 17:31:04 +00:00
|
|
|
@property (nonatomic, strong) SSOAuthenticationPresenter *ssoAuthenticationPresenter;
|
|
|
|
|
2020-12-17 16:39:33 +00:00
|
|
|
// Current SSO flow containing Identity Providers. Used for `socialLoginListView`
|
|
|
|
@property (nonatomic, strong) MXLoginSSOFlow *currentLoginSSOFlow;
|
|
|
|
|
2021-01-07 13:38:27 +00:00
|
|
|
// Current SSO transaction id used to identify and validate the SSO authentication callback
|
|
|
|
@property (nonatomic, strong) NSString *ssoCallbackTxnId;
|
|
|
|
|
2021-02-05 17:32:36 +00:00
|
|
|
@property (nonatomic, strong) CrossSigningService *crossSigningService;
|
|
|
|
|
2021-01-22 10:13:25 +00:00
|
|
|
@property (nonatomic, getter = isFirstViewAppearing) BOOL firstViewAppearing;
|
|
|
|
|
2021-06-28 14:45:20 +00:00
|
|
|
@property (nonatomic, strong) MXKErrorAlertPresentation *errorPresenter;
|
|
|
|
|
2016-05-09 11:56:37 +00:00
|
|
|
@end
|
|
|
|
|
2015-02-05 10:43:06 +00:00
|
|
|
@implementation AuthenticationViewController
|
2014-10-08 12:14:12 +00:00
|
|
|
|
2016-01-27 11:40:26 +00:00
|
|
|
+ (UINib *)nib
|
|
|
|
{
|
|
|
|
return [UINib nibWithNibName:NSStringFromClass(self)
|
|
|
|
bundle:[NSBundle bundleForClass:self]];
|
|
|
|
}
|
|
|
|
|
|
|
|
+ (instancetype)authenticationViewController
|
|
|
|
{
|
|
|
|
return [[[self class] alloc] initWithNibName:NSStringFromClass(self)
|
|
|
|
bundle:[NSBundle bundleForClass:self]];
|
|
|
|
}
|
|
|
|
|
2016-05-03 13:54:05 +00:00
|
|
|
#pragma mark -
|
|
|
|
|
2017-01-03 13:40:23 +00:00
|
|
|
- (void)finalizeInit
|
2015-09-28 08:23:33 +00:00
|
|
|
{
|
2017-01-03 13:40:23 +00:00
|
|
|
[super finalizeInit];
|
2015-02-10 15:12:58 +00:00
|
|
|
|
2016-02-10 21:12:17 +00:00
|
|
|
// Setup `MXKViewControllerHandling` properties
|
|
|
|
self.enableBarTintColorStatusChange = NO;
|
2015-04-14 08:55:18 +00:00
|
|
|
self.rageShakeManager = [RageShakeManager sharedManager];
|
2017-03-10 10:09:46 +00:00
|
|
|
|
2017-03-10 13:48:34 +00:00
|
|
|
// Set a default country code
|
|
|
|
// Note: this value is used only when no MCC and no local country code is available.
|
2017-03-10 10:09:46 +00:00
|
|
|
defaultCountryCode = @"GB";
|
2020-09-14 19:06:12 +00:00
|
|
|
|
|
|
|
didCheckFalseAuthScreenDisplay = NO;
|
2021-01-22 10:13:25 +00:00
|
|
|
|
|
|
|
_firstViewAppearing = YES;
|
2021-02-05 17:32:36 +00:00
|
|
|
|
|
|
|
self.crossSigningService = [CrossSigningService new];
|
2021-06-28 14:45:20 +00:00
|
|
|
self.errorPresenter = [MXKErrorAlertPresentation new];
|
2017-01-03 13:40:23 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
- (void)viewDidLoad
|
|
|
|
{
|
|
|
|
[super viewDidLoad];
|
2015-09-28 08:23:33 +00:00
|
|
|
|
2016-09-15 09:53:29 +00:00
|
|
|
self.mainNavigationItem.title = nil;
|
2021-09-28 05:40:01 +00:00
|
|
|
self.rightBarButtonItem.title = [VectorL10n authRegister];
|
2016-01-27 17:17:43 +00:00
|
|
|
|
2020-07-31 10:47:28 +00:00
|
|
|
self.defaultHomeServerUrl = RiotSettings.shared.homeserverUrlString;
|
2016-01-27 17:17:43 +00:00
|
|
|
|
2020-07-31 10:47:28 +00:00
|
|
|
self.defaultIdentityServerUrl = RiotSettings.shared.identityServerUrlString;
|
2015-04-14 08:55:18 +00:00
|
|
|
|
2020-07-08 17:08:27 +00:00
|
|
|
self.welcomeImageView.image = [UIImage imageNamed:@"horizontal_logo"];
|
2015-09-28 08:23:33 +00:00
|
|
|
|
2016-01-27 11:40:26 +00:00
|
|
|
[self.submitButton.layer setCornerRadius:5];
|
|
|
|
self.submitButton.clipsToBounds = YES;
|
2021-09-28 05:40:01 +00:00
|
|
|
[self.submitButton setTitle:[VectorL10n authLogin] forState:UIControlStateNormal];
|
|
|
|
[self.submitButton setTitle:[VectorL10n authLogin] forState:UIControlStateHighlighted];
|
2016-04-01 14:31:13 +00:00
|
|
|
self.submitButton.enabled = YES;
|
2015-09-28 08:23:33 +00:00
|
|
|
|
2017-03-01 10:43:08 +00:00
|
|
|
[self.skipButton.layer setCornerRadius:5];
|
|
|
|
self.skipButton.clipsToBounds = YES;
|
2021-09-28 05:40:01 +00:00
|
|
|
[self.skipButton setTitle:[VectorL10n authSkip] forState:UIControlStateNormal];
|
|
|
|
[self.skipButton setTitle:[VectorL10n authSkip] forState:UIControlStateHighlighted];
|
2017-03-01 10:43:08 +00:00
|
|
|
self.skipButton.enabled = YES;
|
|
|
|
|
|
|
|
[self.customServersTickButton setImage:[UIImage imageNamed:@"selection_untick"] forState:UIControlStateNormal];
|
|
|
|
[self.customServersTickButton setImage:[UIImage imageNamed:@"selection_untick"] forState:UIControlStateHighlighted];
|
2016-01-27 17:17:43 +00:00
|
|
|
|
2020-07-30 16:07:16 +00:00
|
|
|
if (!BuildSettings.authScreenShowRegister)
|
|
|
|
{
|
|
|
|
self.rightBarButtonItem.enabled = NO;
|
|
|
|
self.rightBarButtonItem.title = nil;
|
|
|
|
}
|
|
|
|
self.serverOptionsContainer.hidden = !BuildSettings.authScreenShowCustomServerOptions;
|
|
|
|
|
2017-03-01 10:43:08 +00:00
|
|
|
[self hideCustomServers:YES];
|
2019-07-23 12:45:51 +00:00
|
|
|
|
|
|
|
// Soft logout section
|
|
|
|
self.softLogoutClearDataButton.layer.cornerRadius = 5;
|
|
|
|
self.softLogoutClearDataButton.clipsToBounds = YES;
|
2021-09-28 05:40:01 +00:00
|
|
|
[self.softLogoutClearDataButton setTitle:[VectorL10n authSoftlogoutClearDataButton] forState:UIControlStateNormal];
|
|
|
|
[self.softLogoutClearDataButton setTitle:[VectorL10n authSoftlogoutClearDataButton] forState:UIControlStateHighlighted];
|
2019-07-23 12:45:51 +00:00
|
|
|
self.softLogoutClearDataButton.enabled = YES;
|
|
|
|
self.softLogoutClearDataContainer.hidden = YES;
|
2016-01-27 17:17:43 +00:00
|
|
|
|
2015-04-30 14:19:12 +00:00
|
|
|
// The view controller dismiss itself on successful login.
|
|
|
|
self.delegate = self;
|
2015-09-28 08:23:33 +00:00
|
|
|
|
2021-09-28 05:40:01 +00:00
|
|
|
self.homeServerTextField.placeholder = [VectorL10n authHomeServerPlaceholder];
|
|
|
|
self.identityServerTextField.placeholder = [VectorL10n authIdentityServerPlaceholder];
|
2017-08-11 14:56:09 +00:00
|
|
|
|
2021-06-30 11:33:43 +00:00
|
|
|
self.authenticationActivityIndicatorContainerView.layer.cornerRadius = 5;
|
|
|
|
[self.authenticationActivityIndicator addObserver:self
|
|
|
|
forKeyPath:@"hidden"
|
|
|
|
options:0
|
|
|
|
context:nil];
|
|
|
|
|
2015-09-28 08:23:33 +00:00
|
|
|
// Custom used authInputsView
|
2016-03-29 13:35:37 +00:00
|
|
|
[self registerAuthInputsViewClass:AuthInputsView.class forAuthType:MXKAuthenticationTypeLogin];
|
|
|
|
[self registerAuthInputsViewClass:AuthInputsView.class forAuthType:MXKAuthenticationTypeRegister];
|
2016-05-03 13:54:05 +00:00
|
|
|
[self registerAuthInputsViewClass:ForgotPasswordInputsView.class forAuthType:MXKAuthenticationTypeForgotPassword];
|
2016-01-28 12:54:50 +00:00
|
|
|
|
|
|
|
// Initialize the auth inputs display
|
2016-03-29 13:35:37 +00:00
|
|
|
AuthInputsView *authInputsView = [AuthInputsView authInputsView];
|
|
|
|
MXAuthenticationSession *authSession = [MXAuthenticationSession modelFromJSON:@{@"flows":@[@{@"stages":@[kMXLoginFlowTypePassword]}]}];
|
|
|
|
[authInputsView setAuthSession:authSession withAuthType:MXKAuthenticationTypeLogin];
|
|
|
|
self.authInputsView = authInputsView;
|
2019-03-04 15:52:22 +00:00
|
|
|
|
|
|
|
// Listen to action within the child view
|
|
|
|
[authInputsView.ssoButton addTarget:self action:@selector(onButtonPressed:) forControlEvents:UIControlEventTouchUpInside];
|
|
|
|
|
2017-07-21 09:28:17 +00:00
|
|
|
// Observe user interface theme change.
|
2019-01-11 09:32:56 +00:00
|
|
|
kThemeServiceDidChangeThemeNotificationObserver = [[NSNotificationCenter defaultCenter] addObserverForName:kThemeServiceDidChangeThemeNotification object:nil queue:[NSOperationQueue mainQueue] usingBlock:^(NSNotification *notif) {
|
2017-07-21 09:28:17 +00:00
|
|
|
|
|
|
|
[self userInterfaceThemeDidChange];
|
|
|
|
|
|
|
|
}];
|
2020-04-28 16:52:03 +00:00
|
|
|
universalLinkDidChangeNotificationObserver = [[NSNotificationCenter defaultCenter] addObserverForName:AppDelegateUniversalLinkDidChangeNotification object:nil queue:nil usingBlock:^(NSNotification * _Nonnull notification) {
|
|
|
|
[self updateUniversalLink];
|
|
|
|
}];
|
|
|
|
|
2017-07-21 09:28:17 +00:00
|
|
|
[self userInterfaceThemeDidChange];
|
2020-04-28 16:52:03 +00:00
|
|
|
[self updateUniversalLink];
|
2020-08-04 14:01:26 +00:00
|
|
|
|
|
|
|
_keyboardAvoider = [[KeyboardAvoider alloc] initWithScrollViewContainerView:self.view scrollView:self.authenticationScrollView];
|
2017-07-21 09:28:17 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
- (void)userInterfaceThemeDidChange
|
|
|
|
{
|
2020-04-22 16:26:49 +00:00
|
|
|
self.navigationBackView.backgroundColor = ThemeService.shared.theme.baseColor;
|
2019-01-11 15:52:28 +00:00
|
|
|
[ThemeService.shared.theme applyStyleOnNavigationBar:self.navigationBar];
|
2019-02-18 11:53:13 +00:00
|
|
|
self.navigationBarSeparatorView.backgroundColor = ThemeService.shared.theme.lineBreakColor;
|
2018-11-29 16:31:41 +00:00
|
|
|
|
2019-01-17 14:35:40 +00:00
|
|
|
// This view controller is not part of a navigation controller
|
|
|
|
// so that applyStyleOnNavigationBar does not fully work.
|
|
|
|
// In order to have the right status bar color, use the expected status bar color
|
|
|
|
// as the main view background color.
|
|
|
|
// Hopefully, subviews define their own background color with `theme.backgroundColor`,
|
|
|
|
// which makes all work together.
|
2020-04-22 16:26:49 +00:00
|
|
|
self.view.backgroundColor = ThemeService.shared.theme.backgroundColor;
|
2018-11-29 16:31:41 +00:00
|
|
|
|
2019-01-11 10:45:27 +00:00
|
|
|
self.authenticationScrollView.backgroundColor = ThemeService.shared.theme.backgroundColor;
|
2020-07-08 17:08:27 +00:00
|
|
|
|
|
|
|
self.welcomeImageView.tintColor = ThemeService.shared.theme.tintColor;
|
2019-03-04 17:20:30 +00:00
|
|
|
|
|
|
|
// Style the authentication fallback webview screen so that its header matches to navigation bar style
|
|
|
|
self.authFallbackContentView.backgroundColor = ThemeService.shared.theme.baseColor;
|
|
|
|
self.cancelAuthFallbackButton.tintColor = ThemeService.shared.theme.baseTextPrimaryColor;
|
2019-01-23 11:03:55 +00:00
|
|
|
|
|
|
|
if (self.homeServerTextField.placeholder)
|
|
|
|
{
|
|
|
|
self.homeServerTextField.attributedPlaceholder = [[NSAttributedString alloc]
|
|
|
|
initWithString:self.homeServerTextField.placeholder
|
|
|
|
attributes:@{NSForegroundColorAttributeName: ThemeService.shared.theme.placeholderTextColor}];
|
|
|
|
}
|
|
|
|
if (self.identityServerTextField.placeholder)
|
2017-08-11 14:56:09 +00:00
|
|
|
{
|
2019-01-23 11:03:55 +00:00
|
|
|
self.identityServerTextField.attributedPlaceholder = [[NSAttributedString alloc]
|
|
|
|
initWithString:self.identityServerTextField.placeholder
|
|
|
|
attributes:@{NSForegroundColorAttributeName: ThemeService.shared.theme.placeholderTextColor}];
|
2017-08-11 14:56:09 +00:00
|
|
|
}
|
|
|
|
|
2019-01-11 10:45:27 +00:00
|
|
|
self.submitButton.backgroundColor = ThemeService.shared.theme.tintColor;
|
|
|
|
self.skipButton.backgroundColor = ThemeService.shared.theme.tintColor;
|
2017-08-11 14:56:09 +00:00
|
|
|
|
2021-06-28 15:38:54 +00:00
|
|
|
self.authenticationActivityIndicator.color = ThemeService.shared.theme.textSecondaryColor;
|
2021-06-30 11:33:43 +00:00
|
|
|
self.authenticationActivityIndicatorContainerView.backgroundColor = ThemeService.shared.theme.baseColor;
|
2019-01-18 12:40:09 +00:00
|
|
|
self.noFlowLabel.textColor = ThemeService.shared.theme.warningColor;
|
2017-08-11 14:56:09 +00:00
|
|
|
|
2021-09-28 05:40:01 +00:00
|
|
|
NSMutableAttributedString *forgotPasswordTitle = [[NSMutableAttributedString alloc] initWithString:[VectorL10n authForgotPassword]];
|
2019-01-07 23:24:11 +00:00
|
|
|
[forgotPasswordTitle addAttribute:NSUnderlineStyleAttributeName value:@(NSUnderlineStyleSingle) range:NSMakeRange(0, forgotPasswordTitle.length)];
|
2019-01-11 10:45:27 +00:00
|
|
|
[forgotPasswordTitle addAttribute:NSForegroundColorAttributeName value:ThemeService.shared.theme.tintColor range:NSMakeRange(0, forgotPasswordTitle.length)];
|
2017-08-11 14:56:09 +00:00
|
|
|
[self.forgotPasswordButton setAttributedTitle:forgotPasswordTitle forState:UIControlStateNormal];
|
|
|
|
[self.forgotPasswordButton setAttributedTitle:forgotPasswordTitle forState:UIControlStateHighlighted];
|
2019-08-13 15:01:01 +00:00
|
|
|
|
|
|
|
NSMutableAttributedString *forgotPasswordTitleDisabled = [[NSMutableAttributedString alloc] initWithAttributedString:forgotPasswordTitle];
|
|
|
|
[forgotPasswordTitleDisabled addAttribute:NSForegroundColorAttributeName value:[ThemeService.shared.theme.tintColor colorWithAlphaComponent:0.3] range:NSMakeRange(0, forgotPasswordTitle.length)];
|
|
|
|
[self.forgotPasswordButton setAttributedTitle:forgotPasswordTitleDisabled forState:UIControlStateDisabled];
|
|
|
|
|
2017-08-11 14:56:09 +00:00
|
|
|
[self updateForgotPwdButtonVisibility];
|
|
|
|
|
2021-09-28 05:40:01 +00:00
|
|
|
NSAttributedString *serverOptionsTitle = [[NSAttributedString alloc] initWithString:[VectorL10n authUseServerOptions] attributes:@{NSForegroundColorAttributeName : ThemeService.shared.theme.textSecondaryColor, NSFontAttributeName: [UIFont systemFontOfSize:14]}];
|
2017-08-11 14:56:09 +00:00
|
|
|
[self.customServersTickButton setAttributedTitle:serverOptionsTitle forState:UIControlStateNormal];
|
|
|
|
[self.customServersTickButton setAttributedTitle:serverOptionsTitle forState:UIControlStateHighlighted];
|
|
|
|
|
2019-02-18 11:53:13 +00:00
|
|
|
self.homeServerSeparator.backgroundColor = ThemeService.shared.theme.lineBreakColor;
|
2019-01-11 10:45:27 +00:00
|
|
|
self.homeServerTextField.textColor = ThemeService.shared.theme.textPrimaryColor;
|
|
|
|
self.homeServerLabel.textColor = ThemeService.shared.theme.textSecondaryColor;
|
2017-07-21 09:28:17 +00:00
|
|
|
|
2019-02-18 11:53:13 +00:00
|
|
|
self.identityServerSeparator.backgroundColor = ThemeService.shared.theme.lineBreakColor;
|
2019-01-11 10:45:27 +00:00
|
|
|
self.identityServerTextField.textColor = ThemeService.shared.theme.textPrimaryColor;
|
|
|
|
self.identityServerLabel.textColor = ThemeService.shared.theme.textSecondaryColor;
|
2018-11-29 16:31:41 +00:00
|
|
|
|
2019-01-11 10:45:27 +00:00
|
|
|
self.activityIndicator.backgroundColor = ThemeService.shared.theme.overlayBackgroundColor;
|
2019-07-23 12:45:51 +00:00
|
|
|
|
|
|
|
self.softLogoutClearDataLabel.textColor = ThemeService.shared.theme.textPrimaryColor;
|
|
|
|
self.softLogoutClearDataButton.backgroundColor = ThemeService.shared.theme.warningColor;
|
2020-07-09 16:58:44 +00:00
|
|
|
|
|
|
|
self.customServersTickButton.tintColor = ThemeService.shared.theme.tintColor;
|
2019-07-23 12:45:51 +00:00
|
|
|
|
2017-08-11 14:56:09 +00:00
|
|
|
[self.authInputsView customizeViewRendering];
|
|
|
|
|
|
|
|
[self setNeedsStatusBarAppearanceUpdate];
|
|
|
|
}
|
|
|
|
|
2020-04-28 16:52:03 +00:00
|
|
|
- (void)updateUniversalLink
|
|
|
|
{
|
|
|
|
UniversalLink *link = [AppDelegate theDelegate].lastHandledUniversalLink;
|
|
|
|
if (link)
|
|
|
|
{
|
|
|
|
NSString *emailAddress = link.queryParams[@"email"];
|
|
|
|
if (emailAddress && self.authInputsView)
|
|
|
|
{
|
|
|
|
AuthInputsView *inputsView = (AuthInputsView *)self.authInputsView;
|
|
|
|
inputsView.emailTextField.text = emailAddress;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2017-08-11 14:56:09 +00:00
|
|
|
- (UIStatusBarStyle)preferredStatusBarStyle
|
|
|
|
{
|
2019-01-11 10:45:27 +00:00
|
|
|
return ThemeService.shared.theme.statusBarStyle;
|
2015-09-28 08:23:33 +00:00
|
|
|
}
|
|
|
|
|
2016-06-03 15:29:34 +00:00
|
|
|
- (void)viewWillAppear:(BOOL)animated
|
|
|
|
{
|
|
|
|
[super viewWillAppear:animated];
|
2017-12-22 12:19:40 +00:00
|
|
|
|
|
|
|
// Screen tracking
|
2018-06-27 07:55:06 +00:00
|
|
|
[[Analytics sharedInstance] trackScreen:@"Authentication"];
|
2020-08-04 14:01:26 +00:00
|
|
|
|
|
|
|
[_keyboardAvoider startAvoiding];
|
2016-06-03 15:29:34 +00:00
|
|
|
}
|
|
|
|
|
2018-02-06 11:48:34 +00:00
|
|
|
- (void)viewDidAppear:(BOOL)animated
|
|
|
|
{
|
|
|
|
[super viewDidAppear:animated];
|
2020-04-03 14:30:06 +00:00
|
|
|
|
2021-01-22 10:13:25 +00:00
|
|
|
if (self.isFirstViewAppearing)
|
|
|
|
{
|
|
|
|
self.firstViewAppearing = NO;
|
|
|
|
}
|
|
|
|
|
2020-04-03 14:30:06 +00:00
|
|
|
if (self.keyVerificationCoordinatorBridgePresenter)
|
|
|
|
{
|
|
|
|
return;
|
|
|
|
}
|
2018-02-06 11:48:34 +00:00
|
|
|
|
2018-02-06 11:50:10 +00:00
|
|
|
// Verify that the app does not show the authentification screean whereas
|
|
|
|
// the user has already logged in.
|
2018-02-06 11:48:34 +00:00
|
|
|
// This bug rarely happens (https://github.com/vector-im/riot-ios/issues/1643)
|
2018-02-06 11:50:10 +00:00
|
|
|
// but it invites the user to log in again. They will then lose all their
|
|
|
|
// e2e messages.
|
2020-09-14 19:06:12 +00:00
|
|
|
if (!didCheckFalseAuthScreenDisplay)
|
2018-02-06 11:48:34 +00:00
|
|
|
{
|
2020-09-14 19:06:12 +00:00
|
|
|
didCheckFalseAuthScreenDisplay = YES;
|
|
|
|
|
2021-06-03 08:30:07 +00:00
|
|
|
MXLogDebug(@"[AuthenticationVC] viewDidAppear: Checking false logout");
|
2020-09-14 19:06:12 +00:00
|
|
|
[[MXKAccountManager sharedManager] forceReloadAccounts];
|
|
|
|
if ([MXKAccountManager sharedManager].activeAccounts.count)
|
|
|
|
{
|
|
|
|
// For now, we do not have better solution than forcing the user to restart the app
|
|
|
|
[NSException raise:@"False logout. Kill the app" format:@"AuthenticationViewController has been displayed whereas there is an existing account"];
|
|
|
|
}
|
2018-02-06 11:48:34 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2020-08-04 14:01:26 +00:00
|
|
|
- (void)viewDidDisappear:(BOOL)animated
|
|
|
|
{
|
|
|
|
[_keyboardAvoider stopAvoiding];
|
|
|
|
|
|
|
|
[super viewDidDisappear:animated];
|
|
|
|
}
|
|
|
|
|
2021-01-22 10:13:25 +00:00
|
|
|
- (void)viewDidLayoutSubviews
|
|
|
|
{
|
|
|
|
[super viewDidLayoutSubviews];
|
|
|
|
|
|
|
|
if (self.isFirstViewAppearing)
|
|
|
|
{
|
|
|
|
[self refreshContentViewHeightConstraint];
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2017-07-21 09:28:17 +00:00
|
|
|
- (void)destroy
|
|
|
|
{
|
|
|
|
[super destroy];
|
|
|
|
|
2019-01-11 09:32:56 +00:00
|
|
|
if (kThemeServiceDidChangeThemeNotificationObserver)
|
2017-07-21 09:28:17 +00:00
|
|
|
{
|
2019-01-11 09:32:56 +00:00
|
|
|
[[NSNotificationCenter defaultCenter] removeObserver:kThemeServiceDidChangeThemeNotificationObserver];
|
|
|
|
kThemeServiceDidChangeThemeNotificationObserver = nil;
|
2017-07-21 09:28:17 +00:00
|
|
|
}
|
2019-03-07 09:08:39 +00:00
|
|
|
|
2020-04-28 16:52:03 +00:00
|
|
|
if (universalLinkDidChangeNotificationObserver)
|
|
|
|
{
|
|
|
|
[[NSNotificationCenter defaultCenter] removeObserver:universalLinkDidChangeNotificationObserver];
|
|
|
|
universalLinkDidChangeNotificationObserver = nil;
|
|
|
|
}
|
2021-07-26 14:16:27 +00:00
|
|
|
|
|
|
|
[self.authenticationActivityIndicator removeObserver:self forKeyPath:@"hidden"];
|
2020-04-28 16:52:03 +00:00
|
|
|
|
2019-03-07 09:08:39 +00:00
|
|
|
autoDiscovery = nil;
|
2020-04-03 14:30:06 +00:00
|
|
|
_keyVerificationCoordinatorBridgePresenter = nil;
|
2020-08-04 14:01:26 +00:00
|
|
|
_keyboardAvoider = nil;
|
2017-07-21 09:28:17 +00:00
|
|
|
}
|
|
|
|
|
2019-08-14 12:11:06 +00:00
|
|
|
- (BOOL)isIdentityServerConfigured
|
|
|
|
{
|
|
|
|
return self.identityServerTextField.text.length > 0;
|
|
|
|
}
|
|
|
|
|
2015-09-28 08:23:33 +00:00
|
|
|
- (void)setAuthType:(MXKAuthenticationType)authType
|
|
|
|
{
|
2017-03-01 10:43:08 +00:00
|
|
|
if (self.authType == MXKAuthenticationTypeRegister)
|
|
|
|
{
|
|
|
|
// Restore the default registration screen
|
|
|
|
[self updateRegistrationScreenWithThirdPartyIdentifiersHidden:YES];
|
|
|
|
}
|
|
|
|
|
2015-09-28 08:23:33 +00:00
|
|
|
super.authType = authType;
|
2020-04-28 08:21:53 +00:00
|
|
|
|
2015-09-28 08:23:33 +00:00
|
|
|
if (authType == MXKAuthenticationTypeLogin)
|
|
|
|
{
|
2021-09-28 05:40:01 +00:00
|
|
|
[self.submitButton setTitle:[VectorL10n authLogin] forState:UIControlStateNormal];
|
|
|
|
[self.submitButton setTitle:[VectorL10n authLogin] forState:UIControlStateHighlighted];
|
2015-09-28 08:23:33 +00:00
|
|
|
}
|
2016-05-03 13:54:05 +00:00
|
|
|
else if (authType == MXKAuthenticationTypeRegister)
|
2015-09-28 08:23:33 +00:00
|
|
|
{
|
2021-09-28 05:40:01 +00:00
|
|
|
[self.submitButton setTitle:[VectorL10n authRegister] forState:UIControlStateNormal];
|
|
|
|
[self.submitButton setTitle:[VectorL10n authRegister] forState:UIControlStateHighlighted];
|
2015-09-28 08:23:33 +00:00
|
|
|
}
|
2016-05-03 13:54:05 +00:00
|
|
|
else if (authType == MXKAuthenticationTypeForgotPassword)
|
|
|
|
{
|
|
|
|
if (isPasswordReseted)
|
|
|
|
{
|
2021-09-28 05:40:01 +00:00
|
|
|
[self.submitButton setTitle:[VectorL10n authReturnToLogin] forState:UIControlStateNormal];
|
|
|
|
[self.submitButton setTitle:[VectorL10n authReturnToLogin] forState:UIControlStateHighlighted];
|
2016-05-03 13:54:05 +00:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2021-09-28 05:40:01 +00:00
|
|
|
[self.submitButton setTitle:[VectorL10n authSendResetEmail] forState:UIControlStateNormal];
|
|
|
|
[self.submitButton setTitle:[VectorL10n authSendResetEmail] forState:UIControlStateHighlighted];
|
2016-05-03 13:54:05 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2020-12-17 16:39:33 +00:00
|
|
|
[self updateAuthInputViewVisibility];
|
2016-06-02 12:33:21 +00:00
|
|
|
[self updateForgotPwdButtonVisibility];
|
2019-07-23 15:15:16 +00:00
|
|
|
[self updateSoftLogoutClearDataContainerVisibility];
|
2020-12-17 16:39:33 +00:00
|
|
|
[self updateSocialLoginViewVisibility];
|
2015-02-10 15:12:58 +00:00
|
|
|
}
|
|
|
|
|
2016-05-09 22:00:07 +00:00
|
|
|
- (void)setAuthInputsView:(MXKAuthInputsView *)authInputsView
|
|
|
|
{
|
2017-03-10 10:09:46 +00:00
|
|
|
// Keep the current country code if any.
|
|
|
|
if ([self.authInputsView isKindOfClass:AuthInputsView.class])
|
|
|
|
{
|
|
|
|
// We will reuse the current country code
|
|
|
|
defaultCountryCode = ((AuthInputsView*)self.authInputsView).isoCountryCode;
|
|
|
|
}
|
|
|
|
|
|
|
|
// Finalize the new auth inputs view
|
|
|
|
if ([authInputsView isKindOfClass:AuthInputsView.class])
|
|
|
|
{
|
|
|
|
AuthInputsView *authInputsview = (AuthInputsView*)authInputsView;
|
|
|
|
|
|
|
|
// Retrieve the MCC from the SIM card information (Note: the phone book country code is not defined yet)
|
|
|
|
NSString *countryCode = [MXKAppSettings standardAppSettings].phonebookCountryCode;
|
|
|
|
if (!countryCode)
|
|
|
|
{
|
|
|
|
// If none, consider the preferred locale
|
2019-01-07 23:24:11 +00:00
|
|
|
NSLocale *local = [[NSLocale alloc] initWithLocaleIdentifier:[[NSBundle mainBundle] preferredLocalizations][0]];
|
2017-03-10 10:09:46 +00:00
|
|
|
if ([local respondsToSelector:@selector(countryCode)])
|
|
|
|
{
|
|
|
|
countryCode = local.countryCode;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (!countryCode)
|
|
|
|
{
|
|
|
|
countryCode = defaultCountryCode;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
authInputsview.isoCountryCode = countryCode;
|
|
|
|
authInputsview.delegate = self;
|
|
|
|
}
|
|
|
|
|
2016-05-09 22:00:07 +00:00
|
|
|
[super setAuthInputsView:authInputsView];
|
|
|
|
|
|
|
|
// Restore here the actual content view height.
|
|
|
|
// Indeed this height has been modified according to the authInputsView height in the default implementation of MXKAuthenticationViewController.
|
2016-05-27 12:24:35 +00:00
|
|
|
[self refreshContentViewHeightConstraint];
|
2021-06-29 08:45:07 +00:00
|
|
|
|
|
|
|
// the authentication indicator should be the front most view
|
2021-06-30 11:33:43 +00:00
|
|
|
[self.authInputsContainerView bringSubviewToFront:self.authenticationActivityIndicatorContainerView];
|
2016-05-09 22:00:07 +00:00
|
|
|
}
|
|
|
|
|
2020-12-17 16:39:33 +00:00
|
|
|
- (void)updateAuthInputViewVisibility
|
|
|
|
{
|
|
|
|
BOOL hideAuthInputView = NO;
|
|
|
|
|
|
|
|
// Hide input view when there is only social login actions to present
|
|
|
|
if ((self.authType == MXKAuthenticationTypeLogin || self.authType == MXKAuthenticationTypeRegister)
|
|
|
|
&& self.currentLoginSSOFlow
|
|
|
|
&& !self.isAuthSessionContainsPasswordFlow)
|
|
|
|
{
|
|
|
|
hideAuthInputView = YES;
|
|
|
|
}
|
|
|
|
|
|
|
|
self.authInputsView.hidden = hideAuthInputView;
|
|
|
|
}
|
|
|
|
|
2016-04-01 14:31:13 +00:00
|
|
|
- (void)setUserInteractionEnabled:(BOOL)userInteractionEnabled
|
|
|
|
{
|
|
|
|
super.userInteractionEnabled = userInteractionEnabled;
|
2019-03-04 16:25:21 +00:00
|
|
|
|
|
|
|
// Reset
|
|
|
|
self.rightBarButtonItem.enabled = YES;
|
2016-04-01 14:31:13 +00:00
|
|
|
|
|
|
|
// Show/Hide server options
|
2016-05-27 12:24:35 +00:00
|
|
|
if (_optionsContainer.hidden == userInteractionEnabled)
|
|
|
|
{
|
|
|
|
_optionsContainer.hidden = !userInteractionEnabled;
|
|
|
|
|
|
|
|
[self refreshContentViewHeightConstraint];
|
|
|
|
}
|
2016-04-07 07:28:27 +00:00
|
|
|
|
|
|
|
// Update the label of the right bar button according to its actual action.
|
|
|
|
if (!userInteractionEnabled)
|
|
|
|
{
|
|
|
|
// The right bar button is used to cancel the running request.
|
2021-09-28 05:40:01 +00:00
|
|
|
self.rightBarButtonItem.title = [VectorL10n cancel];
|
2017-03-01 10:43:08 +00:00
|
|
|
|
|
|
|
// Remove the potential back button.
|
|
|
|
self.mainNavigationItem.leftBarButtonItem = nil;
|
2016-04-07 07:28:27 +00:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2019-03-04 16:25:21 +00:00
|
|
|
AuthInputsView *authInputsview;
|
|
|
|
if ([self.authInputsView isKindOfClass:AuthInputsView.class])
|
|
|
|
{
|
|
|
|
authInputsview = (AuthInputsView*)self.authInputsView;
|
|
|
|
}
|
|
|
|
|
2016-04-07 07:28:27 +00:00
|
|
|
// The right bar button is used to switch the authentication type.
|
|
|
|
if (self.authType == MXKAuthenticationTypeLogin)
|
|
|
|
{
|
2020-07-30 16:07:16 +00:00
|
|
|
if (!authInputsview.isSingleSignOnRequired
|
|
|
|
&& !self.softLogoutCredentials
|
|
|
|
&& BuildSettings.authScreenShowRegister)
|
2019-03-04 16:25:21 +00:00
|
|
|
{
|
2021-09-28 05:40:01 +00:00
|
|
|
self.rightBarButtonItem.title = [VectorL10n authRegister];
|
2019-03-04 16:25:21 +00:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
// Disable register on SSO
|
|
|
|
self.rightBarButtonItem.enabled = NO;
|
|
|
|
self.rightBarButtonItem.title = nil;
|
|
|
|
}
|
2016-04-07 07:28:27 +00:00
|
|
|
}
|
2016-05-03 13:54:05 +00:00
|
|
|
else if (self.authType == MXKAuthenticationTypeRegister)
|
2016-04-07 07:28:27 +00:00
|
|
|
{
|
2021-09-28 05:40:01 +00:00
|
|
|
self.rightBarButtonItem.title = [VectorL10n authLogin];
|
2017-03-01 10:43:08 +00:00
|
|
|
|
|
|
|
// Restore the back button
|
2019-03-04 16:25:21 +00:00
|
|
|
if (authInputsview)
|
2017-03-01 10:43:08 +00:00
|
|
|
{
|
|
|
|
[self updateRegistrationScreenWithThirdPartyIdentifiersHidden:authInputsview.thirdPartyIdentifiersHidden];
|
|
|
|
}
|
2016-04-07 07:28:27 +00:00
|
|
|
}
|
2016-05-03 13:54:05 +00:00
|
|
|
else if (self.authType == MXKAuthenticationTypeForgotPassword)
|
|
|
|
{
|
|
|
|
// The right bar button is used to return to login.
|
2021-09-28 05:40:01 +00:00
|
|
|
self.rightBarButtonItem.title = [VectorL10n cancel];
|
2016-05-03 13:54:05 +00:00
|
|
|
}
|
2016-04-07 07:28:27 +00:00
|
|
|
}
|
2016-04-01 14:31:13 +00:00
|
|
|
}
|
|
|
|
|
2020-04-03 14:30:06 +00:00
|
|
|
- (void)presentCompleteSecurityWithSession:(MXSession*)session
|
|
|
|
{
|
|
|
|
KeyVerificationCoordinatorBridgePresenter *keyVerificationCoordinatorBridgePresenter = [[KeyVerificationCoordinatorBridgePresenter alloc] initWithSession:session];
|
|
|
|
keyVerificationCoordinatorBridgePresenter.delegate = self;
|
|
|
|
|
|
|
|
if (self.navigationController)
|
|
|
|
{
|
2020-04-23 09:58:19 +00:00
|
|
|
[keyVerificationCoordinatorBridgePresenter pushCompleteSecurityFrom:self.navigationController isNewSignIn:YES animated:YES];
|
2020-04-03 14:30:06 +00:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2020-04-23 09:58:19 +00:00
|
|
|
[keyVerificationCoordinatorBridgePresenter presentCompleteSecurityFrom:self isNewSignIn:YES animated:YES];
|
2020-04-03 14:30:06 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
self.keyVerificationCoordinatorBridgePresenter = keyVerificationCoordinatorBridgePresenter;
|
|
|
|
}
|
|
|
|
|
|
|
|
- (void)dismiss
|
|
|
|
{
|
|
|
|
self.userInteractionEnabled = YES;
|
|
|
|
[self.authenticationActivityIndicator stopAnimating];
|
|
|
|
|
|
|
|
// Remove auth view controller on successful login
|
|
|
|
if (self.navigationController)
|
|
|
|
{
|
|
|
|
// Pop the view controller
|
|
|
|
[self.navigationController popViewControllerAnimated:YES];
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
// Dismiss on successful login
|
|
|
|
[self.presentingViewController dismissViewControllerAnimated:YES completion:nil];
|
|
|
|
}
|
2020-09-15 14:48:35 +00:00
|
|
|
|
|
|
|
if (self.authVCDelegate)
|
|
|
|
{
|
|
|
|
[self.authVCDelegate authenticationViewControllerDidDismiss:self];
|
|
|
|
}
|
2020-04-03 14:30:06 +00:00
|
|
|
}
|
2019-09-16 08:43:30 +00:00
|
|
|
|
2021-01-07 13:38:27 +00:00
|
|
|
- (BOOL)continueSSOLoginWithToken:(NSString*)loginToken txnId:(NSString*)txnId
|
|
|
|
{
|
|
|
|
// Check if transaction id is the same as expected
|
|
|
|
if (loginToken &&
|
|
|
|
txnId && self.ssoCallbackTxnId
|
|
|
|
&& [txnId isEqualToString:self.ssoCallbackTxnId])
|
|
|
|
{
|
|
|
|
[self loginWithToken:loginToken];
|
|
|
|
return YES;
|
|
|
|
}
|
|
|
|
|
2021-06-03 08:30:07 +00:00
|
|
|
MXLogDebug(@"[AuthenticationVC] Fail to continue SSO login");
|
2021-01-07 13:38:27 +00:00
|
|
|
return NO;
|
|
|
|
}
|
|
|
|
|
2019-09-16 08:43:30 +00:00
|
|
|
#pragma mark - Fallback URL display
|
|
|
|
|
|
|
|
- (void)showAuthenticationFallBackView:(NSString*)fallbackPage
|
|
|
|
{
|
|
|
|
// Skip MatrixKit and use a VC instead
|
|
|
|
if (self.softLogoutCredentials)
|
|
|
|
{
|
|
|
|
// Add device_id as query param of the fallback
|
|
|
|
NSURLComponents *components = [[NSURLComponents alloc] initWithString:fallbackPage];
|
|
|
|
|
|
|
|
NSMutableArray<NSURLQueryItem*> *queryItems = [components.queryItems mutableCopy];
|
|
|
|
if (!queryItems)
|
|
|
|
{
|
|
|
|
queryItems = [NSMutableArray array];
|
|
|
|
}
|
|
|
|
|
|
|
|
[queryItems addObject:[NSURLQueryItem queryItemWithName:@"device_id"
|
|
|
|
value:self.softLogoutCredentials.deviceId]];
|
|
|
|
|
|
|
|
components.queryItems = queryItems;
|
|
|
|
|
|
|
|
fallbackPage = components.URL.absoluteString;
|
|
|
|
}
|
|
|
|
|
|
|
|
[self showAuthenticationFallBackViewController:fallbackPage];
|
|
|
|
}
|
|
|
|
|
|
|
|
- (void)showAuthenticationFallBackViewController:(NSString*)fallbackPage
|
|
|
|
{
|
|
|
|
authFallBackViewController = [[AuthFallBackViewController alloc] initWithURL:fallbackPage];
|
|
|
|
authFallBackViewController.delegate = self;
|
|
|
|
|
|
|
|
|
|
|
|
authFallBackViewController.navigationItem.leftBarButtonItem = [[UIBarButtonItem alloc] initWithBarButtonSystemItem:UIBarButtonSystemItemCancel target:self action:@selector(dismissFallBackViewController:)];
|
|
|
|
|
2020-04-08 15:02:00 +00:00
|
|
|
UINavigationController *navigationController = [[RiotNavigationController alloc] initWithRootViewController:authFallBackViewController];
|
2019-09-16 08:43:30 +00:00
|
|
|
[self presentViewController:navigationController animated:YES completion:nil];
|
|
|
|
}
|
|
|
|
|
|
|
|
- (void)dismissFallBackViewController:(id)sender
|
|
|
|
{
|
|
|
|
[authFallBackViewController dismissViewControllerAnimated:YES completion:nil];
|
|
|
|
authFallBackViewController = nil;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
#pragma mark AuthFallBackViewControllerDelegate
|
|
|
|
|
|
|
|
- (void)authFallBackViewController:(AuthFallBackViewController *)authFallBackViewController
|
|
|
|
didLoginWithLoginResponse:(MXLoginResponse *)loginResponse
|
|
|
|
{
|
|
|
|
[authFallBackViewController dismissViewControllerAnimated:YES completion:^{
|
|
|
|
|
|
|
|
MXCredentials *credentials = [[MXCredentials alloc] initWithLoginResponse:loginResponse andDefaultCredentials:nil];
|
|
|
|
[self onSuccessfulLogin:credentials];
|
|
|
|
}];
|
|
|
|
|
|
|
|
authFallBackViewController = nil;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
- (void)authFallBackViewControllerDidClose:(AuthFallBackViewController *)authFallBackViewController
|
|
|
|
{
|
|
|
|
[self dismissFallBackViewController:nil];
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2019-07-19 12:25:45 +00:00
|
|
|
- (void)setSoftLogoutCredentials:(MXCredentials *)softLogoutCredentials
|
|
|
|
{
|
|
|
|
[super setSoftLogoutCredentials:softLogoutCredentials];
|
|
|
|
|
|
|
|
// Customise the screen for soft logout
|
|
|
|
self.customServersTickButton.hidden = YES;
|
2019-07-23 09:51:46 +00:00
|
|
|
self.rightBarButtonItem.title = nil;
|
2021-09-28 05:40:01 +00:00
|
|
|
self.mainNavigationItem.title = [VectorL10n authSoftlogoutSignedOut];
|
2019-07-23 09:51:46 +00:00
|
|
|
|
2019-07-23 15:15:16 +00:00
|
|
|
[self showSoftLogoutClearDataContainer];
|
2019-07-23 12:45:51 +00:00
|
|
|
}
|
|
|
|
|
2019-07-23 15:15:16 +00:00
|
|
|
- (void)showSoftLogoutClearDataContainer
|
2019-07-23 12:45:51 +00:00
|
|
|
{
|
2021-09-28 05:40:01 +00:00
|
|
|
NSMutableAttributedString *message = [[NSMutableAttributedString alloc] initWithString:[VectorL10n authSoftlogoutClearData]
|
2019-07-23 12:45:51 +00:00
|
|
|
attributes:@{
|
|
|
|
NSFontAttributeName: [UIFont boldSystemFontOfSize:14]
|
|
|
|
}];
|
2021-09-28 05:40:01 +00:00
|
|
|
|
2019-07-23 12:45:51 +00:00
|
|
|
[message appendAttributedString:[[NSAttributedString alloc] initWithString:@"\n\n"]];
|
2021-09-28 05:40:01 +00:00
|
|
|
|
2019-07-23 12:45:51 +00:00
|
|
|
NSString *string = [NSString stringWithFormat:@"%@\n\n%@",
|
2021-09-28 05:40:01 +00:00
|
|
|
[VectorL10n authSoftlogoutClearDataMessage1],
|
|
|
|
[VectorL10n authSoftlogoutClearDataMessage2]];
|
2019-07-23 12:45:51 +00:00
|
|
|
|
|
|
|
[message appendAttributedString:[[NSAttributedString alloc] initWithString:string
|
|
|
|
attributes:@{
|
|
|
|
NSFontAttributeName: [UIFont systemFontOfSize:14]
|
|
|
|
}]];
|
|
|
|
self.softLogoutClearDataLabel.attributedText = message;
|
|
|
|
|
|
|
|
self.softLogoutClearDataContainer.hidden = NO;
|
|
|
|
[self refreshContentViewHeightConstraint];
|
2019-07-19 12:25:45 +00:00
|
|
|
}
|
|
|
|
|
2019-07-23 15:15:16 +00:00
|
|
|
- (void)updateSoftLogoutClearDataContainerVisibility
|
|
|
|
{
|
|
|
|
// Do not display it in case of forget password flow
|
|
|
|
if (self.softLogoutCredentials && self.authType == MXKAuthenticationTypeLogin)
|
|
|
|
{
|
|
|
|
self.softLogoutClearDataContainer.hidden = NO;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
self.softLogoutClearDataContainer.hidden = YES;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2019-07-23 14:20:07 +00:00
|
|
|
- (void)showClearDataAfterSoftLogoutConfirmation
|
|
|
|
{
|
|
|
|
// Request confirmation
|
|
|
|
if (alert)
|
|
|
|
{
|
|
|
|
[alert dismissViewControllerAnimated:NO completion:nil];
|
|
|
|
}
|
|
|
|
|
2021-09-28 05:40:01 +00:00
|
|
|
alert = [UIAlertController alertControllerWithTitle:[VectorL10n authSoftlogoutClearDataSignOutTitle]
|
2021-10-08 08:23:56 +00:00
|
|
|
message:[VectorL10n authSoftlogoutClearDataSignOutMsg]
|
2019-07-23 14:20:07 +00:00
|
|
|
preferredStyle:UIAlertControllerStyleAlert];
|
|
|
|
|
|
|
|
|
2021-09-28 05:40:01 +00:00
|
|
|
[alert addAction:[UIAlertAction actionWithTitle:[VectorL10n authSoftlogoutClearDataSignOut]
|
|
|
|
style:UIAlertActionStyleDestructive
|
2019-07-23 14:20:07 +00:00
|
|
|
handler:^(UIAlertAction * action)
|
|
|
|
{
|
|
|
|
[self clearDataAfterSoftLogout];
|
|
|
|
}]];
|
|
|
|
|
|
|
|
MXWeakify(self);
|
2021-09-28 05:40:01 +00:00
|
|
|
[alert addAction:[UIAlertAction actionWithTitle:[MatrixKitL10n cancel]
|
2019-07-23 14:20:07 +00:00
|
|
|
style:UIAlertActionStyleDefault
|
|
|
|
handler:^(UIAlertAction * action)
|
|
|
|
{
|
|
|
|
MXStrongifyAndReturnIfNil(self);
|
|
|
|
self->alert = nil;
|
|
|
|
}]];
|
|
|
|
|
|
|
|
[self presentViewController:alert animated:YES completion:nil];
|
|
|
|
}
|
|
|
|
|
|
|
|
- (void)clearDataAfterSoftLogout
|
|
|
|
{
|
2021-06-03 08:30:07 +00:00
|
|
|
MXLogDebug(@"[AuthenticationVC] clearDataAfterSoftLogout %@", self.softLogoutCredentials.userId);
|
2019-07-23 14:20:07 +00:00
|
|
|
|
|
|
|
// Use AppDelegate so that we reset app settings and this auth screen
|
|
|
|
[[AppDelegate theDelegate] logoutSendingRequestServer:YES completion:^(BOOL isLoggedOut) {
|
2021-06-03 08:30:07 +00:00
|
|
|
MXLogDebug(@"[AuthenticationVC] Complete. isLoggedOut: %@", @(isLoggedOut));
|
2019-07-23 14:20:07 +00:00
|
|
|
}];
|
|
|
|
}
|
|
|
|
|
2019-09-10 12:33:41 +00:00
|
|
|
/**
|
|
|
|
Filter and prioritise flows supported by the app.
|
|
|
|
|
|
|
|
@param authSession the auth session coming from the HS.
|
|
|
|
@return a new auth session
|
|
|
|
*/
|
|
|
|
- (MXAuthenticationSession*)handleSupportedFlowsInAuthenticationSession:(MXAuthenticationSession *)authSession
|
|
|
|
{
|
2020-12-17 16:39:33 +00:00
|
|
|
MXLoginSSOFlow *ssoFlow;
|
|
|
|
MXLoginFlow *passwordFlow;
|
2019-09-10 12:33:41 +00:00
|
|
|
NSMutableArray *supportedFlows = [NSMutableArray array];
|
|
|
|
|
|
|
|
for (MXLoginFlow *flow in authSession.flows)
|
|
|
|
{
|
|
|
|
// Remove known flows we do not support
|
|
|
|
if (![flow.type isEqualToString:kMXLoginFlowTypeToken])
|
|
|
|
{
|
2021-06-03 08:30:07 +00:00
|
|
|
MXLogDebug(@"[AuthenticationVC] handleSupportedFlowsInAuthenticationSession: Filter out flow %@", flow.type);
|
2019-09-10 12:33:41 +00:00
|
|
|
[supportedFlows addObject:flow];
|
|
|
|
}
|
|
|
|
|
2020-12-17 16:39:33 +00:00
|
|
|
if ([flow.type isEqualToString:kMXLoginFlowTypePassword])
|
|
|
|
{
|
|
|
|
passwordFlow = flow;
|
|
|
|
}
|
|
|
|
|
|
|
|
if ([flow isKindOfClass:MXLoginSSOFlow.class])
|
2019-09-10 12:33:41 +00:00
|
|
|
{
|
2021-06-03 08:30:07 +00:00
|
|
|
MXLogDebug(@"[AuthenticationVC] handleSupportedFlowsInAuthenticationSession: Prioritise flow %@", flow.type);
|
2020-12-17 16:39:33 +00:00
|
|
|
ssoFlow = (MXLoginSSOFlow *)flow;
|
2019-09-10 12:33:41 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2020-12-17 16:39:33 +00:00
|
|
|
// Prioritise SSO over other flows
|
2019-09-10 12:33:41 +00:00
|
|
|
if (ssoFlow)
|
|
|
|
{
|
|
|
|
[supportedFlows removeAllObjects];
|
|
|
|
[supportedFlows addObject:ssoFlow];
|
2020-12-17 16:39:33 +00:00
|
|
|
|
|
|
|
// If the SSO contains Identity Providers list and password
|
|
|
|
// Display both social login and password input
|
|
|
|
if (ssoFlow.identityProviders.count && passwordFlow)
|
|
|
|
{
|
|
|
|
[supportedFlows addObject:passwordFlow];
|
|
|
|
}
|
2019-09-10 12:33:41 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
if (supportedFlows.count != authSession.flows.count)
|
|
|
|
{
|
|
|
|
MXAuthenticationSession *updatedAuthSession = [[MXAuthenticationSession alloc] init];
|
|
|
|
updatedAuthSession.session = authSession.session;
|
|
|
|
updatedAuthSession.params = authSession.params;
|
|
|
|
updatedAuthSession.flows = supportedFlows;
|
|
|
|
return updatedAuthSession;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
return authSession;
|
|
|
|
}
|
|
|
|
}
|
2019-07-19 12:25:45 +00:00
|
|
|
|
2019-03-04 15:52:22 +00:00
|
|
|
- (void)handleAuthenticationSession:(MXAuthenticationSession *)authSession
|
|
|
|
{
|
2019-09-10 12:33:41 +00:00
|
|
|
// Make some cleaning from the server response according to what the app supports
|
|
|
|
authSession = [self handleSupportedFlowsInAuthenticationSession:authSession];
|
|
|
|
|
2019-03-04 15:52:22 +00:00
|
|
|
[super handleAuthenticationSession:authSession];
|
2020-12-17 16:39:33 +00:00
|
|
|
|
|
|
|
self.currentLoginSSOFlow = [self logginSSOFlowWithProvidersFromFlows:authSession.flows];
|
|
|
|
|
|
|
|
[self updateAuthInputViewVisibility];
|
|
|
|
[self updateSocialLoginViewVisibility];
|
|
|
|
|
2019-03-04 15:52:22 +00:00
|
|
|
AuthInputsView *authInputsview;
|
|
|
|
if ([self.authInputsView isKindOfClass:AuthInputsView.class])
|
|
|
|
{
|
|
|
|
authInputsview = (AuthInputsView*)self.authInputsView;
|
2020-04-28 16:52:03 +00:00
|
|
|
[self updateUniversalLink];
|
2019-03-04 15:52:22 +00:00
|
|
|
}
|
2019-07-24 12:59:40 +00:00
|
|
|
|
|
|
|
// Hide "Forgot password" and "Log in" buttons in case of SSO
|
|
|
|
[self updateForgotPwdButtonVisibility];
|
|
|
|
[self updateSoftLogoutClearDataContainerVisibility];
|
|
|
|
|
2020-12-17 16:39:33 +00:00
|
|
|
self.submitButton.hidden = authInputsview.isSingleSignOnRequired || authInputsview.isHidden;
|
2019-07-24 12:59:40 +00:00
|
|
|
|
|
|
|
// Bind ssoButton again if self.authInputsView has changed
|
|
|
|
[authInputsview.ssoButton addTarget:self action:@selector(onButtonPressed:) forControlEvents:UIControlEventTouchUpInside];
|
|
|
|
|
|
|
|
if (authInputsview.isSingleSignOnRequired && self.softLogoutCredentials)
|
|
|
|
{
|
|
|
|
// Remove submitButton so that the 2nd contraint on softLogoutClearDataContainer.top will be applied
|
|
|
|
// That makes softLogoutClearDataContainer appear upper in the screen
|
|
|
|
[self.submitButton removeFromSuperview];
|
|
|
|
}
|
2020-12-17 16:39:33 +00:00
|
|
|
|
|
|
|
[self refreshContentViewHeightConstraint];
|
|
|
|
}
|
|
|
|
|
|
|
|
- (BOOL)isAuthSessionContainsPasswordFlow
|
|
|
|
{
|
|
|
|
BOOL containsPassword = NO;
|
|
|
|
|
|
|
|
if (self.authInputsView.authSession)
|
|
|
|
{
|
|
|
|
containsPassword = [self containsPasswordFlowInFlows:self.authInputsView.authSession.flows];
|
|
|
|
}
|
|
|
|
|
|
|
|
return containsPassword;
|
|
|
|
}
|
|
|
|
|
|
|
|
- (BOOL)containsPasswordFlowInFlows:(NSArray<MXLoginFlow*>*)loginFlows
|
|
|
|
{
|
|
|
|
for (MXLoginFlow *loginFlow in loginFlows)
|
|
|
|
{
|
|
|
|
if ([loginFlow.type isEqualToString:kMXLoginFlowTypePassword])
|
|
|
|
{
|
|
|
|
return YES;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
return NO;
|
|
|
|
}
|
|
|
|
|
|
|
|
- (MXLoginSSOFlow*)logginSSOFlowWithProvidersFromFlows:(NSArray<MXLoginFlow*>*)loginFlows
|
|
|
|
{
|
|
|
|
MXLoginSSOFlow *ssoFlowWithProviders;
|
|
|
|
|
|
|
|
for (MXLoginFlow *loginFlow in loginFlows)
|
|
|
|
{
|
|
|
|
if ([loginFlow isKindOfClass:MXLoginSSOFlow.class])
|
|
|
|
{
|
|
|
|
MXLoginSSOFlow *ssoFlow = (MXLoginSSOFlow *)loginFlow;
|
|
|
|
|
|
|
|
if (ssoFlow.identityProviders.count)
|
|
|
|
{
|
|
|
|
ssoFlowWithProviders = ssoFlow;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
return ssoFlowWithProviders;
|
2019-03-04 15:52:22 +00:00
|
|
|
}
|
|
|
|
|
2016-01-27 17:17:43 +00:00
|
|
|
- (IBAction)onButtonPressed:(id)sender
|
|
|
|
{
|
2017-03-01 10:43:08 +00:00
|
|
|
if (sender == self.customServersTickButton)
|
2016-01-27 17:17:43 +00:00
|
|
|
{
|
2017-03-01 10:43:08 +00:00
|
|
|
[self hideCustomServers:!self.customServersContainer.hidden];
|
2016-01-27 17:17:43 +00:00
|
|
|
}
|
|
|
|
else if (sender == self.forgotPasswordButton)
|
|
|
|
{
|
2019-08-14 12:11:06 +00:00
|
|
|
if (!self.isIdentityServerConfigured)
|
|
|
|
{
|
2021-09-28 05:40:01 +00:00
|
|
|
UIAlertController *alert = [UIAlertController alertControllerWithTitle:[MatrixKitL10n error]
|
|
|
|
message:[VectorL10n authForgotPasswordErrorNoConfiguredIdentityServer]
|
2019-08-14 12:11:06 +00:00
|
|
|
preferredStyle:UIAlertControllerStyleAlert];
|
2021-09-28 05:40:01 +00:00
|
|
|
[alert addAction:[UIAlertAction actionWithTitle:[MatrixKitL10n ok] style:UIAlertActionStyleDefault handler:nil]];
|
2019-08-14 12:11:06 +00:00
|
|
|
[self presentViewController:alert animated:YES completion:nil];
|
|
|
|
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
// Update UI to reset password
|
|
|
|
self.authType = MXKAuthenticationTypeForgotPassword;
|
|
|
|
}
|
2016-01-27 17:17:43 +00:00
|
|
|
}
|
|
|
|
else if (sender == self.rightBarButtonItem)
|
|
|
|
{
|
2016-04-07 07:28:27 +00:00
|
|
|
// Check whether a request is in progress
|
|
|
|
if (!self.userInteractionEnabled)
|
|
|
|
{
|
2016-04-21 15:53:52 +00:00
|
|
|
// Cancel the current operation
|
|
|
|
[self cancel];
|
2016-04-07 07:28:27 +00:00
|
|
|
}
|
|
|
|
else if (self.authType == MXKAuthenticationTypeLogin)
|
2016-01-27 17:17:43 +00:00
|
|
|
{
|
|
|
|
self.authType = MXKAuthenticationTypeRegister;
|
2021-09-28 05:40:01 +00:00
|
|
|
self.rightBarButtonItem.title = [VectorL10n authLogin];
|
2016-01-27 17:17:43 +00:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
self.authType = MXKAuthenticationTypeLogin;
|
2021-09-28 05:40:01 +00:00
|
|
|
self.rightBarButtonItem.title = [VectorL10n authRegister];
|
2016-01-27 17:17:43 +00:00
|
|
|
}
|
|
|
|
}
|
2017-03-01 10:43:08 +00:00
|
|
|
else if (sender == self.mainNavigationItem.leftBarButtonItem)
|
2016-04-01 14:31:13 +00:00
|
|
|
{
|
2017-03-01 10:43:08 +00:00
|
|
|
if ([self.authInputsView isKindOfClass:AuthInputsView.class])
|
2016-04-01 14:31:13 +00:00
|
|
|
{
|
2017-03-01 10:43:08 +00:00
|
|
|
AuthInputsView *authInputsview = (AuthInputsView*)self.authInputsView;
|
2016-04-01 14:31:13 +00:00
|
|
|
|
2017-03-01 10:43:08 +00:00
|
|
|
// Hide the supported 3rd party ids which may be added to the account
|
|
|
|
authInputsview.thirdPartyIdentifiersHidden = YES;
|
2016-04-01 14:31:13 +00:00
|
|
|
|
2017-03-01 10:43:08 +00:00
|
|
|
[self updateRegistrationScreenWithThirdPartyIdentifiersHidden:YES];
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else if (sender == self.submitButton)
|
|
|
|
{
|
|
|
|
// Handle here the second screen used to manage the 3rd party ids during the registration.
|
2017-03-20 18:43:24 +00:00
|
|
|
// Except if there is an external set of parameters defined to perform a registration.
|
|
|
|
if (self.authType == MXKAuthenticationTypeRegister && !self.externalRegistrationParameters)
|
2017-03-01 10:43:08 +00:00
|
|
|
{
|
|
|
|
// Sanity check
|
|
|
|
if ([self.authInputsView isKindOfClass:AuthInputsView.class])
|
|
|
|
{
|
|
|
|
AuthInputsView *authInputsview = (AuthInputsView*)self.authInputsView;
|
2016-06-04 15:39:56 +00:00
|
|
|
|
2017-03-01 10:43:08 +00:00
|
|
|
// Show the 3rd party ids screen if it is not shown yet
|
2017-03-05 17:21:37 +00:00
|
|
|
if (authInputsview.areThirdPartyIdentifiersSupported && authInputsview.isThirdPartyIdentifiersHidden)
|
2017-03-01 10:43:08 +00:00
|
|
|
{
|
|
|
|
[self dismissKeyboard];
|
|
|
|
|
|
|
|
[self.authenticationActivityIndicator startAnimating];
|
|
|
|
|
|
|
|
// Check parameters validity
|
|
|
|
NSString *errorMsg = [self.authInputsView validateParameters];
|
|
|
|
if (errorMsg)
|
|
|
|
{
|
|
|
|
[self onFailureDuringAuthRequest:[NSError errorWithDomain:MXKAuthErrorDomain code:0 userInfo:@{NSLocalizedDescriptionKey:errorMsg}]];
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2018-08-20 16:30:50 +00:00
|
|
|
[self testUserRegistration:^(MXError *mxError) {
|
|
|
|
// We consider that a user can be registered if:
|
|
|
|
// - the username is not already in use
|
|
|
|
if ([mxError.errcode isEqualToString:kMXErrCodeStringUserInUse])
|
2017-03-01 10:43:08 +00:00
|
|
|
{
|
2021-06-03 08:30:07 +00:00
|
|
|
MXLogDebug(@"[AuthenticationVC] User name is already use");
|
2021-09-28 05:40:01 +00:00
|
|
|
[self onFailureDuringAuthRequest:[NSError errorWithDomain:MXKAuthErrorDomain code:0 userInfo:@{NSLocalizedDescriptionKey:[VectorL10n authUsernameInUse]}]];
|
2017-03-01 10:43:08 +00:00
|
|
|
}
|
2018-08-20 16:30:50 +00:00
|
|
|
// - the server quota limits is not reached
|
|
|
|
else if ([mxError.errcode isEqualToString:kMXErrCodeStringResourceLimitExceeded])
|
|
|
|
{
|
|
|
|
[self showResourceLimitExceededError:mxError.userInfo];
|
|
|
|
}
|
2017-03-01 10:43:08 +00:00
|
|
|
else
|
|
|
|
{
|
|
|
|
[self.authenticationActivityIndicator stopAnimating];
|
2019-09-06 08:30:20 +00:00
|
|
|
|
|
|
|
// Show the supported 3rd party ids which may be added to the account
|
|
|
|
authInputsview.thirdPartyIdentifiersHidden = NO;
|
|
|
|
[self updateRegistrationScreenWithThirdPartyIdentifiersHidden:NO];
|
2017-03-01 10:43:08 +00:00
|
|
|
}
|
|
|
|
}];
|
|
|
|
}
|
|
|
|
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
}
|
2016-04-01 14:31:13 +00:00
|
|
|
}
|
2017-03-01 10:43:08 +00:00
|
|
|
|
|
|
|
[super onButtonPressed:sender];
|
|
|
|
}
|
|
|
|
else if (sender == self.skipButton)
|
|
|
|
{
|
|
|
|
// Reset the potential email or phone values
|
|
|
|
if ([self.authInputsView isKindOfClass:AuthInputsView.class])
|
2016-04-01 14:31:13 +00:00
|
|
|
{
|
2017-03-01 10:43:08 +00:00
|
|
|
AuthInputsView *authInputsview = (AuthInputsView*)self.authInputsView;
|
|
|
|
|
|
|
|
[authInputsview resetThirdPartyIdentifiers];
|
2016-04-01 14:31:13 +00:00
|
|
|
}
|
2017-03-01 10:43:08 +00:00
|
|
|
|
|
|
|
[super onButtonPressed:self.submitButton];
|
2016-04-01 14:31:13 +00:00
|
|
|
}
|
2019-03-04 15:52:22 +00:00
|
|
|
else if (sender == ((AuthInputsView*)self.authInputsView).ssoButton)
|
2021-01-07 15:01:17 +00:00
|
|
|
{
|
|
|
|
[self presentDefaultSSOAuthentication];
|
2019-03-04 15:52:22 +00:00
|
|
|
}
|
2019-07-23 14:20:07 +00:00
|
|
|
else if (sender == self.softLogoutClearDataButton)
|
|
|
|
{
|
|
|
|
[self showClearDataAfterSoftLogoutConfirmation];
|
|
|
|
}
|
2016-01-27 17:17:43 +00:00
|
|
|
else
|
|
|
|
{
|
|
|
|
[super onButtonPressed:sender];
|
|
|
|
}
|
2019-07-23 15:15:16 +00:00
|
|
|
|
|
|
|
[self updateSoftLogoutClearDataContainerVisibility];
|
2016-01-27 17:17:43 +00:00
|
|
|
}
|
|
|
|
|
2016-05-09 11:56:37 +00:00
|
|
|
- (void)onFailureDuringAuthRequest:(NSError *)error
|
|
|
|
{
|
2020-04-28 08:21:53 +00:00
|
|
|
MXError *mxError = [[MXError alloc] initWithNSError:error];
|
|
|
|
if ([mxError.errcode isEqualToString:kMXErrCodeStringResourceLimitExceeded])
|
2016-05-09 22:00:07 +00:00
|
|
|
{
|
2020-04-28 08:21:53 +00:00
|
|
|
[self showResourceLimitExceededError:mxError.userInfo];
|
2016-05-09 22:00:07 +00:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2020-04-28 08:21:53 +00:00
|
|
|
[super onFailureDuringAuthRequest:error];
|
2016-05-09 22:00:07 +00:00
|
|
|
}
|
2016-05-09 11:56:37 +00:00
|
|
|
}
|
|
|
|
|
2017-03-05 17:21:37 +00:00
|
|
|
- (void)onSuccessfulLogin:(MXCredentials*)credentials
|
|
|
|
{
|
2020-09-15 14:47:13 +00:00
|
|
|
// Is pin protection forced?
|
|
|
|
if ([PinCodePreferences shared].forcePinProtection)
|
2017-03-05 17:21:37 +00:00
|
|
|
{
|
2020-07-17 16:03:00 +00:00
|
|
|
loginCredentials = credentials;
|
|
|
|
|
2020-09-17 17:42:49 +00:00
|
|
|
SetPinCoordinatorViewMode viewMode = SetPinCoordinatorViewModeSetPin;
|
|
|
|
switch (self.authType) {
|
|
|
|
case MXKAuthenticationTypeLogin:
|
|
|
|
viewMode = SetPinCoordinatorViewModeSetPinAfterLogin;
|
|
|
|
break;
|
|
|
|
case MXKAuthenticationTypeRegister:
|
|
|
|
viewMode = SetPinCoordinatorViewModeSetPinAfterRegister;
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
SetPinCoordinatorBridgePresenter *presenter = [[SetPinCoordinatorBridgePresenter alloc] initWithSession:nil viewMode:viewMode];
|
2020-07-21 13:14:46 +00:00
|
|
|
presenter.delegate = self;
|
|
|
|
[presenter presentFrom:self animated:YES];
|
|
|
|
self.setPinCoordinatorBridgePresenter = presenter;
|
|
|
|
return;
|
2017-03-05 17:21:37 +00:00
|
|
|
}
|
|
|
|
|
2020-07-17 16:03:00 +00:00
|
|
|
[self afterSetPinFlowCompletedWithCredentials:credentials];
|
2017-03-05 17:21:37 +00:00
|
|
|
}
|
|
|
|
|
2016-06-02 12:33:21 +00:00
|
|
|
- (void)updateForgotPwdButtonVisibility
|
|
|
|
{
|
2019-03-04 15:52:22 +00:00
|
|
|
AuthInputsView *authInputsview;
|
|
|
|
if ([self.authInputsView isKindOfClass:AuthInputsView.class])
|
|
|
|
{
|
|
|
|
authInputsview = (AuthInputsView*)self.authInputsView;
|
|
|
|
}
|
2020-08-19 15:32:35 +00:00
|
|
|
|
|
|
|
BOOL showForgotPasswordButton = NO;
|
2019-03-04 15:52:22 +00:00
|
|
|
|
2020-12-17 16:39:33 +00:00
|
|
|
if (BuildSettings.authScreenShowForgotPassword && authInputsview.isHidden == NO)
|
2020-08-19 15:32:35 +00:00
|
|
|
{
|
2020-08-20 08:47:52 +00:00
|
|
|
showForgotPasswordButton = (self.authType == MXKAuthenticationTypeLogin) && !authInputsview.isSingleSignOnRequired;
|
2020-08-19 15:32:35 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
self.forgotPasswordButton.hidden = !showForgotPasswordButton;
|
2016-06-02 12:33:21 +00:00
|
|
|
|
|
|
|
// Adjust minimum leading constraint of the submit button
|
|
|
|
if (self.forgotPasswordButton.isHidden)
|
|
|
|
{
|
|
|
|
self.submitButtonMinLeadingConstraint.constant = 19;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
CGRect frame = self.forgotPasswordButton.frame;
|
|
|
|
self.submitButtonMinLeadingConstraint.constant = frame.origin.x + frame.size.width + 10;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2020-07-17 16:03:00 +00:00
|
|
|
- (void)afterSetPinFlowCompletedWithCredentials:(MXCredentials*)credentials
|
|
|
|
{
|
|
|
|
// Check whether a third party identifiers has not been used
|
|
|
|
if ([self.authInputsView isKindOfClass:AuthInputsView.class])
|
|
|
|
{
|
|
|
|
AuthInputsView *authInputsview = (AuthInputsView*)self.authInputsView;
|
|
|
|
if (authInputsview.isThirdPartyIdentifierPending)
|
|
|
|
{
|
|
|
|
// Alert user
|
|
|
|
if (alert)
|
|
|
|
{
|
|
|
|
[alert dismissViewControllerAnimated:NO completion:nil];
|
|
|
|
}
|
|
|
|
|
2021-09-28 05:40:01 +00:00
|
|
|
alert = [UIAlertController alertControllerWithTitle:[VectorL10n warning] message:[VectorL10n authAddEmailAndPhoneWarning] preferredStyle:UIAlertControllerStyleAlert];
|
2020-07-17 16:03:00 +00:00
|
|
|
|
2021-09-28 05:40:01 +00:00
|
|
|
[alert addAction:[UIAlertAction actionWithTitle:[MatrixKitL10n ok]
|
2020-07-17 16:03:00 +00:00
|
|
|
style:UIAlertActionStyleDefault
|
|
|
|
handler:^(UIAlertAction * action) {
|
|
|
|
|
|
|
|
[super onSuccessfulLogin:credentials];
|
|
|
|
|
|
|
|
}]];
|
|
|
|
|
|
|
|
[self presentViewController:alert animated:YES completion:nil];
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
[super onSuccessfulLogin:credentials];
|
|
|
|
}
|
|
|
|
|
2016-01-27 17:17:43 +00:00
|
|
|
#pragma mark -
|
|
|
|
|
2017-03-01 10:43:08 +00:00
|
|
|
- (void)updateRegistrationScreenWithThirdPartyIdentifiersHidden:(BOOL)thirdPartyIdentifiersHidden
|
|
|
|
{
|
|
|
|
self.skipButton.hidden = thirdPartyIdentifiersHidden;
|
|
|
|
|
2020-07-21 06:06:37 +00:00
|
|
|
// Do not display the skip button if the 3PID is mandatory
|
|
|
|
if (!thirdPartyIdentifiersHidden)
|
|
|
|
{
|
|
|
|
if ([self.authInputsView isKindOfClass:AuthInputsView.class])
|
|
|
|
{
|
|
|
|
AuthInputsView *authInputsview = (AuthInputsView*)self.authInputsView;
|
|
|
|
if (authInputsview.isThirdPartyIdentifierRequired)
|
|
|
|
{
|
|
|
|
self.skipButton.hidden = YES;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2020-07-30 16:07:16 +00:00
|
|
|
self.serverOptionsContainer.hidden = !thirdPartyIdentifiersHidden
|
|
|
|
|| !BuildSettings.authScreenShowCustomServerOptions;
|
2017-03-01 10:43:08 +00:00
|
|
|
[self refreshContentViewHeightConstraint];
|
|
|
|
|
|
|
|
if (thirdPartyIdentifiersHidden)
|
|
|
|
{
|
2021-09-28 05:40:01 +00:00
|
|
|
[self.submitButton setTitle:[VectorL10n authRegister] forState:UIControlStateNormal];
|
|
|
|
[self.submitButton setTitle:[VectorL10n authRegister] forState:UIControlStateHighlighted];
|
2017-03-01 10:43:08 +00:00
|
|
|
|
|
|
|
self.mainNavigationItem.leftBarButtonItem = nil;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2021-09-28 05:40:01 +00:00
|
|
|
[self.submitButton setTitle:[VectorL10n authSubmit] forState:UIControlStateNormal];
|
|
|
|
[self.submitButton setTitle:[VectorL10n authSubmit] forState:UIControlStateHighlighted];
|
2017-03-01 10:43:08 +00:00
|
|
|
|
|
|
|
UIBarButtonItem *leftBarButtonItem = [[UIBarButtonItem alloc] initWithImage:[UIImage imageNamed:@"back_icon"] style:UIBarButtonItemStylePlain target:self action:@selector(onButtonPressed:)];
|
|
|
|
self.mainNavigationItem.leftBarButtonItem = leftBarButtonItem;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2016-05-27 12:24:35 +00:00
|
|
|
- (void)refreshContentViewHeightConstraint
|
|
|
|
{
|
2021-01-15 16:05:45 +00:00
|
|
|
[self.view layoutIfNeeded];
|
|
|
|
|
2016-05-27 12:24:35 +00:00
|
|
|
// Refresh content view height by considering the options container display.
|
2017-03-01 10:43:08 +00:00
|
|
|
CGFloat constant = self.optionsContainer.frame.origin.y + 10;
|
2016-05-27 12:24:35 +00:00
|
|
|
|
2020-12-17 16:39:33 +00:00
|
|
|
if (self.authInputsView.isHidden == NO)
|
|
|
|
{
|
|
|
|
self.authInputContainerViewMinHeightConstraint.constant = kAuthInputContainerViewMinHeightConstraintConstant;
|
|
|
|
self.authInputContainerViewHeightConstraint.constant = self.authInputsView.viewHeightConstraint.constant;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
self.authInputContainerViewMinHeightConstraint.constant = 0;
|
|
|
|
self.authInputContainerViewHeightConstraint.constant = 0;
|
|
|
|
}
|
2021-01-15 16:05:45 +00:00
|
|
|
|
|
|
|
// FIX: When authInputsView present recaptcha the height is not taken into account, add it manually here.
|
|
|
|
AuthInputsView *authInputsview;
|
|
|
|
if ([self.authInputsView isKindOfClass:AuthInputsView.class])
|
|
|
|
{
|
|
|
|
authInputsview = (AuthInputsView*)self.authInputsView;
|
|
|
|
|
|
|
|
if (!authInputsview.recaptchaContainer.hidden)
|
|
|
|
{
|
|
|
|
constant+=authInputsview.frame.size.height;
|
|
|
|
}
|
|
|
|
}
|
2020-12-17 16:39:33 +00:00
|
|
|
|
2016-05-27 12:24:35 +00:00
|
|
|
if (!self.optionsContainer.isHidden)
|
|
|
|
{
|
2017-03-01 10:43:08 +00:00
|
|
|
constant += self.serverOptionsContainer.frame.origin.y;
|
|
|
|
|
2016-05-27 12:24:35 +00:00
|
|
|
if (!self.serverOptionsContainer.isHidden)
|
|
|
|
{
|
2017-03-01 10:43:08 +00:00
|
|
|
CGRect customServersContainerFrame = self.customServersContainer.frame;
|
|
|
|
constant += customServersContainerFrame.origin.y;
|
|
|
|
|
|
|
|
if (!self.customServersContainer.isHidden)
|
|
|
|
{
|
|
|
|
constant += customServersContainerFrame.size.height;
|
|
|
|
}
|
2020-08-04 10:03:44 +00:00
|
|
|
else
|
|
|
|
{
|
|
|
|
constant += self.customServersTickButton.frame.size.height;
|
|
|
|
}
|
2016-05-27 12:24:35 +00:00
|
|
|
}
|
|
|
|
}
|
2019-07-23 12:45:51 +00:00
|
|
|
|
|
|
|
if (!self.softLogoutClearDataContainer.isHidden)
|
|
|
|
{
|
|
|
|
// The soft logout clear data section adds more height
|
|
|
|
constant += self.softLogoutClearDataContainer.frame.size.height;
|
|
|
|
}
|
2020-12-17 16:39:33 +00:00
|
|
|
|
|
|
|
if (self.isSocialLoginViewShown)
|
|
|
|
{
|
|
|
|
constant += [self socialLoginViewHeightFittingWidth:self.contentView.frame.size.width];
|
|
|
|
}
|
2019-07-23 12:45:51 +00:00
|
|
|
|
2017-03-01 10:43:08 +00:00
|
|
|
self.contentViewHeightConstraint.constant = constant;
|
2020-12-17 16:39:33 +00:00
|
|
|
|
|
|
|
[self.view layoutIfNeeded];
|
2016-05-27 12:24:35 +00:00
|
|
|
}
|
|
|
|
|
2017-03-01 10:43:08 +00:00
|
|
|
- (void)hideCustomServers:(BOOL)hidden
|
2016-01-27 17:17:43 +00:00
|
|
|
{
|
2017-03-01 10:43:08 +00:00
|
|
|
if (self.customServersContainer.isHidden == hidden)
|
2016-01-27 17:17:43 +00:00
|
|
|
{
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (hidden)
|
|
|
|
{
|
|
|
|
[self.homeServerTextField resignFirstResponder];
|
|
|
|
[self.identityServerTextField resignFirstResponder];
|
|
|
|
|
2016-04-05 16:43:52 +00:00
|
|
|
// Report server url typed by the user as custom url.
|
|
|
|
NSString *homeServerURL = self.homeServerTextField.text;
|
|
|
|
if (homeServerURL.length && ![homeServerURL isEqualToString:self.defaultHomeServerUrl])
|
|
|
|
{
|
|
|
|
[[NSUserDefaults standardUserDefaults] setObject:homeServerURL forKey:@"customHomeServerURL"];
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
[[NSUserDefaults standardUserDefaults] removeObjectForKey:@"customHomeServerURL"];
|
|
|
|
}
|
|
|
|
|
|
|
|
NSString *identityServerURL = self.identityServerTextField.text;
|
|
|
|
if (identityServerURL.length && ![identityServerURL isEqualToString:self.defaultIdentityServerUrl])
|
|
|
|
{
|
|
|
|
[[NSUserDefaults standardUserDefaults] setObject:identityServerURL forKey:@"customIdentityServerURL"];
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
[[NSUserDefaults standardUserDefaults] removeObjectForKey:@"customIdentityServerURL"];
|
|
|
|
}
|
2018-10-15 21:49:17 +00:00
|
|
|
|
2016-04-05 16:43:52 +00:00
|
|
|
// Restore default configuration
|
|
|
|
[self setHomeServerTextFieldText:self.defaultHomeServerUrl];
|
|
|
|
[self setIdentityServerTextFieldText:self.defaultIdentityServerUrl];
|
|
|
|
|
2017-03-01 10:43:08 +00:00
|
|
|
[self.customServersTickButton setImage:[UIImage imageNamed:@"selection_untick"] forState:UIControlStateNormal];
|
|
|
|
self.customServersContainer.hidden = YES;
|
2016-01-27 17:17:43 +00:00
|
|
|
|
|
|
|
// Refresh content view height
|
2017-03-01 10:43:08 +00:00
|
|
|
self.contentViewHeightConstraint.constant -= self.customServersContainer.frame.size.height;
|
2016-01-27 17:17:43 +00:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2016-04-05 16:43:52 +00:00
|
|
|
// Load custom configuration
|
|
|
|
NSString *customHomeServerURL = [[NSUserDefaults standardUserDefaults] objectForKey:@"customHomeServerURL"];
|
|
|
|
if (customHomeServerURL.length)
|
|
|
|
{
|
|
|
|
[self setHomeServerTextFieldText:customHomeServerURL];
|
|
|
|
}
|
2019-08-30 14:27:49 +00:00
|
|
|
else
|
|
|
|
{
|
2019-09-02 15:14:22 +00:00
|
|
|
[self checkIdentityServer];
|
2019-08-30 14:27:49 +00:00
|
|
|
}
|
2016-04-05 16:43:52 +00:00
|
|
|
NSString *customIdentityServerURL = [[NSUserDefaults standardUserDefaults] objectForKey:@"customIdentityServerURL"];
|
|
|
|
if (customIdentityServerURL.length)
|
|
|
|
{
|
|
|
|
[self setIdentityServerTextFieldText:customIdentityServerURL];
|
|
|
|
}
|
|
|
|
|
2017-03-01 10:43:08 +00:00
|
|
|
[self.customServersTickButton setImage:[UIImage imageNamed:@"selection_tick"] forState:UIControlStateNormal];
|
|
|
|
self.customServersContainer.hidden = NO;
|
2016-01-27 17:17:43 +00:00
|
|
|
|
|
|
|
// Refresh content view height
|
2020-12-17 16:39:33 +00:00
|
|
|
[self refreshContentViewHeightConstraint];
|
2016-01-27 17:17:43 +00:00
|
|
|
|
|
|
|
// Scroll to display server options
|
|
|
|
CGPoint offset = self.authenticationScrollView.contentOffset;
|
2017-03-01 10:43:08 +00:00
|
|
|
offset.y += self.customServersContainer.frame.size.height;
|
2016-01-27 17:17:43 +00:00
|
|
|
self.authenticationScrollView.contentOffset = offset;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2018-08-20 16:30:50 +00:00
|
|
|
- (void)showResourceLimitExceededError:(NSDictionary *)errorDict
|
|
|
|
{
|
2021-06-03 08:30:07 +00:00
|
|
|
MXLogDebug(@"[AuthenticationVC] showResourceLimitExceededError");
|
2018-08-20 16:30:50 +00:00
|
|
|
|
2020-09-01 10:20:44 +00:00
|
|
|
[self showResourceLimitExceededError:errorDict onAdminContactTapped:^(NSURL *adminContactURL) {
|
|
|
|
|
|
|
|
[[UIApplication sharedApplication] vc_open:adminContactURL completionHandler:^(BOOL success) {
|
|
|
|
if (!success)
|
|
|
|
{
|
2021-06-03 08:30:07 +00:00
|
|
|
MXLogDebug(@"[AuthenticationVC] adminContact(%@) cannot be opened", adminContactURL);
|
2020-09-01 10:20:44 +00:00
|
|
|
}
|
|
|
|
}];
|
2018-08-20 16:30:50 +00:00
|
|
|
}];
|
|
|
|
}
|
|
|
|
|
2020-08-04 10:08:44 +00:00
|
|
|
#pragma mark - UITextFieldDelegate
|
|
|
|
|
|
|
|
- (void)textFieldDidBeginEditing:(UITextField *)textField
|
|
|
|
{
|
2020-08-05 12:22:27 +00:00
|
|
|
[self.authenticationScrollView vc_scrollTo:textField with:UIEdgeInsetsMake(-20, 0, -20, 0) animated:YES];
|
2020-08-04 10:08:44 +00:00
|
|
|
}
|
|
|
|
|
2016-05-09 22:00:07 +00:00
|
|
|
#pragma mark - KVO
|
|
|
|
|
|
|
|
- (void)observeValueForKeyPath:(NSString *)keyPath ofObject:(id)object change:(NSDictionary *)change context:(void *)context
|
|
|
|
{
|
|
|
|
// Override here the handling of the authInputsView height change.
|
|
|
|
if ([@"viewHeightConstraint.constant" isEqualToString:keyPath])
|
|
|
|
{
|
2016-05-27 12:24:35 +00:00
|
|
|
// Refresh content view height by considering the updated frame of the options container.
|
|
|
|
[self refreshContentViewHeightConstraint];
|
2016-05-09 22:00:07 +00:00
|
|
|
}
|
2021-06-30 11:33:43 +00:00
|
|
|
else if ([@"hidden" isEqualToString:keyPath])
|
|
|
|
{
|
|
|
|
UIActivityIndicatorView *indicator = (UIActivityIndicatorView*)object;
|
|
|
|
[self.authenticationActivityIndicatorContainerView setHidden:indicator.hidden];
|
|
|
|
}
|
2016-05-09 22:00:07 +00:00
|
|
|
else
|
|
|
|
{
|
|
|
|
[super observeValueForKeyPath:keyPath ofObject:object change:change context:context];
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2015-04-30 14:19:12 +00:00
|
|
|
#pragma mark - MXKAuthenticationViewControllerDelegate
|
2015-02-10 15:12:58 +00:00
|
|
|
|
2016-01-27 11:40:26 +00:00
|
|
|
- (void)authenticationViewController:(MXKAuthenticationViewController *)authenticationViewController didLogWithUserId:(NSString *)userId
|
|
|
|
{
|
2020-04-03 14:30:06 +00:00
|
|
|
self.userInteractionEnabled = NO;
|
|
|
|
[self.authenticationActivityIndicator startAnimating];
|
|
|
|
|
2017-03-01 10:43:08 +00:00
|
|
|
// Hide the custom server details in order to save customized inputs
|
|
|
|
[self hideCustomServers:YES];
|
2015-02-10 15:12:58 +00:00
|
|
|
|
2020-04-03 14:30:06 +00:00
|
|
|
MXKAccount *account = [[MXKAccountManager sharedManager] accountForUserId:userId];
|
|
|
|
MXSession *session = account.mxSession;
|
|
|
|
|
2020-07-08 15:34:50 +00:00
|
|
|
BOOL botCreationEnabled = [[NSUserDefaults standardUserDefaults] boolForKey:@"enableBotCreation"];
|
|
|
|
|
2017-09-15 13:19:36 +00:00
|
|
|
// Create DM with Riot-bot on new account creation.
|
2020-07-08 15:34:50 +00:00
|
|
|
if (self.authType == MXKAuthenticationTypeRegister && botCreationEnabled)
|
2017-09-15 13:19:36 +00:00
|
|
|
{
|
2020-01-28 13:33:56 +00:00
|
|
|
MXRoomCreationParameters *roomCreationParameters = [MXRoomCreationParameters parametersForDirectRoomWithUser:@"@riot-bot:matrix.org"];
|
2020-04-03 14:30:06 +00:00
|
|
|
[session createRoomWithParameters:roomCreationParameters success:nil failure:^(NSError *error) {
|
2021-06-03 08:30:07 +00:00
|
|
|
MXLogDebug(@"[AuthenticationVC] Create chat with riot-bot failed");
|
2020-01-28 13:33:56 +00:00
|
|
|
}];
|
2017-09-15 13:19:36 +00:00
|
|
|
}
|
|
|
|
|
2020-04-03 14:30:06 +00:00
|
|
|
// Wait for session change to present complete security screen if needed
|
|
|
|
[self registerSessionStateChangeNotificationForSession:session];
|
|
|
|
}
|
|
|
|
|
|
|
|
- (void)registerSessionStateChangeNotificationForSession:(MXSession*)session
|
|
|
|
{
|
|
|
|
[[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(sessionStateDidChangeNotification:) name:kMXSessionStateDidChangeNotification object:session];
|
|
|
|
}
|
|
|
|
|
|
|
|
- (void)unregisterSessionStateChangeNotification
|
|
|
|
{
|
|
|
|
[[NSNotificationCenter defaultCenter] removeObserver:self name:kMXSessionStateDidChangeNotification object:nil];
|
|
|
|
}
|
|
|
|
|
|
|
|
- (void)sessionStateDidChangeNotification:(NSNotification*)notification
|
|
|
|
{
|
|
|
|
MXSession *session = (MXSession*)notification.object;
|
2021-01-26 16:33:05 +00:00
|
|
|
|
|
|
|
if (session.state == MXSessionStateStoreDataReady)
|
2016-01-27 11:40:26 +00:00
|
|
|
{
|
2020-04-03 14:30:06 +00:00
|
|
|
if (session.crypto.crossSigning)
|
|
|
|
{
|
2020-04-14 10:55:25 +00:00
|
|
|
// Do not make key share requests while the "Complete security" is not complete.
|
|
|
|
// If the device is self-verified, the SDK will restore the existing key backup.
|
|
|
|
// Then, it will re-enable outgoing key share requests
|
|
|
|
[session.crypto setOutgoingKeyRequestsEnabled:NO onComplete:nil];
|
2021-01-26 16:33:05 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
else if (session.state == MXSessionStateRunning)
|
|
|
|
{
|
|
|
|
[self unregisterSessionStateChangeNotification];
|
|
|
|
|
|
|
|
if (session.crypto.crossSigning)
|
|
|
|
{
|
2020-04-03 14:30:06 +00:00
|
|
|
[session.crypto.crossSigning refreshStateWithSuccess:^(BOOL stateUpdated) {
|
2020-06-02 12:19:37 +00:00
|
|
|
|
2021-06-03 08:30:07 +00:00
|
|
|
MXLogDebug(@"[AuthenticationVC] sessionStateDidChange: crossSigning.state: %@", @(session.crypto.crossSigning.state));
|
2020-06-02 12:19:37 +00:00
|
|
|
|
|
|
|
switch (session.crypto.crossSigning.state)
|
2020-04-03 14:30:06 +00:00
|
|
|
{
|
2020-06-02 12:19:37 +00:00
|
|
|
case MXCrossSigningStateNotBootstrapped:
|
|
|
|
{
|
2020-06-24 15:09:23 +00:00
|
|
|
// TODO: This is still not sure we want to disable the automatic cross-signing bootstrap
|
|
|
|
// if the admin disabled e2e by default.
|
|
|
|
// Do like riot-web for the moment
|
2020-10-08 19:41:46 +00:00
|
|
|
if ([session vc_homeserverConfiguration].isE2EEByDefaultEnabled)
|
2020-06-02 12:19:37 +00:00
|
|
|
{
|
2020-06-24 15:09:23 +00:00
|
|
|
// Bootstrap cross-signing on user's account
|
|
|
|
// We do it for both registration and new login as long as cross-signing does not exist yet
|
|
|
|
if (self.authInputsView.password.length)
|
|
|
|
{
|
2021-06-03 08:30:07 +00:00
|
|
|
MXLogDebug(@"[AuthenticationVC] sessionStateDidChange: Bootstrap with password");
|
2020-06-24 15:09:23 +00:00
|
|
|
|
2020-06-26 05:42:37 +00:00
|
|
|
[session.crypto.crossSigning setupWithPassword:self.authInputsView.password success:^{
|
2021-06-03 08:30:07 +00:00
|
|
|
MXLogDebug(@"[AuthenticationVC] sessionStateDidChange: Bootstrap succeeded");
|
2020-06-24 15:09:23 +00:00
|
|
|
[self dismiss];
|
|
|
|
} failure:^(NSError * _Nonnull error) {
|
2021-06-03 08:30:07 +00:00
|
|
|
MXLogDebug(@"[AuthenticationVC] sessionStateDidChange: Bootstrap failed. Error: %@", error);
|
2020-06-24 15:09:23 +00:00
|
|
|
[session.crypto setOutgoingKeyRequestsEnabled:YES onComplete:nil];
|
|
|
|
[self dismiss];
|
|
|
|
}];
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2021-02-05 17:32:36 +00:00
|
|
|
// Try to setup cross-signing without authentication parameters in case if a grace period is enabled
|
|
|
|
[self.crossSigningService setupCrossSigningWithoutAuthenticationFor:session success:^{
|
2021-06-03 08:30:07 +00:00
|
|
|
MXLogDebug(@"[AuthenticationVC] sessionStateDidChange: Bootstrap succeeded without credentials");
|
2021-02-05 17:32:36 +00:00
|
|
|
[self dismiss];
|
|
|
|
} failure:^(NSError * _Nonnull error) {
|
2021-06-03 08:30:07 +00:00
|
|
|
MXLogDebug(@"[AuthenticationVC] sessionStateDidChange: Do not know how to bootstrap cross-signing. Skip it.");
|
2021-02-05 17:32:36 +00:00
|
|
|
[session.crypto setOutgoingKeyRequestsEnabled:YES onComplete:nil];
|
|
|
|
[self dismiss];
|
|
|
|
}];
|
2020-06-24 15:09:23 +00:00
|
|
|
}
|
2020-06-02 12:19:37 +00:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
[session.crypto setOutgoingKeyRequestsEnabled:YES onComplete:nil];
|
|
|
|
[self dismiss];
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
case MXCrossSigningStateCrossSigningExists:
|
|
|
|
{
|
2021-06-03 08:30:07 +00:00
|
|
|
MXLogDebug(@"[AuthenticationVC] sessionStateDidChange: Complete security");
|
2020-04-03 14:30:06 +00:00
|
|
|
|
2020-06-02 12:19:37 +00:00
|
|
|
// Ask the user to verify this session
|
2020-04-03 14:30:06 +00:00
|
|
|
self.userInteractionEnabled = YES;
|
|
|
|
[self.authenticationActivityIndicator stopAnimating];
|
|
|
|
|
|
|
|
[self presentCompleteSecurityWithSession:session];
|
2020-06-02 12:19:37 +00:00
|
|
|
break;
|
|
|
|
}
|
2020-04-03 14:30:06 +00:00
|
|
|
|
2020-06-02 12:19:37 +00:00
|
|
|
default:
|
2021-06-03 08:30:07 +00:00
|
|
|
MXLogDebug(@"[AuthenticationVC] sessionStateDidChange: Nothing to do");
|
2020-06-02 12:19:37 +00:00
|
|
|
|
|
|
|
[session.crypto setOutgoingKeyRequestsEnabled:YES onComplete:nil];
|
|
|
|
[self dismiss];
|
|
|
|
break;
|
2020-04-03 14:30:06 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
} failure:^(NSError * _Nonnull error) {
|
2021-06-03 08:30:07 +00:00
|
|
|
MXLogDebug(@"[AuthenticationVC] sessionStateDidChange: Fail to refresh crypto state with error: %@", error);
|
2020-06-03 09:24:40 +00:00
|
|
|
[session.crypto setOutgoingKeyRequestsEnabled:YES onComplete:nil];
|
|
|
|
[self dismiss];
|
2020-04-03 14:30:06 +00:00
|
|
|
}];
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
[self dismiss];
|
|
|
|
}
|
2015-05-21 16:15:45 +00:00
|
|
|
}
|
2015-02-24 09:07:50 +00:00
|
|
|
}
|
|
|
|
|
2017-03-05 17:21:37 +00:00
|
|
|
#pragma mark - MXKAuthInputsViewDelegate
|
|
|
|
|
2018-11-27 14:52:05 +00:00
|
|
|
- (void)authInputsView:(MXKAuthInputsView *)authInputsView presentViewController:(UIViewController*)viewControllerToPresent animated:(BOOL)animated
|
2017-03-05 17:21:37 +00:00
|
|
|
{
|
|
|
|
[self dismissKeyboard];
|
2018-11-27 14:52:05 +00:00
|
|
|
[self presentViewController:viewControllerToPresent animated:animated completion:nil];
|
2017-03-05 17:21:37 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
- (void)authInputsViewDidCancelOperation:(MXKAuthInputsView *)authInputsView
|
|
|
|
{
|
|
|
|
[self cancel];
|
|
|
|
}
|
|
|
|
|
2019-03-06 17:30:03 +00:00
|
|
|
- (void)authInputsView:(MXKAuthInputsView *)authInputsView autoDiscoverServerWithDomain:(NSString *)domain
|
|
|
|
{
|
|
|
|
[self tryServerDiscoveryOnDomain:domain];
|
|
|
|
}
|
|
|
|
|
|
|
|
#pragma mark - Server discovery
|
|
|
|
|
|
|
|
- (void)tryServerDiscoveryOnDomain:(NSString *)domain
|
|
|
|
{
|
2019-03-07 09:08:39 +00:00
|
|
|
autoDiscovery = [[MXAutoDiscovery alloc] initWithDomain:domain];
|
2019-03-06 17:30:03 +00:00
|
|
|
|
|
|
|
MXWeakify(self);
|
|
|
|
[autoDiscovery findClientConfig:^(MXDiscoveredClientConfig * _Nonnull discoveredClientConfig) {
|
|
|
|
MXStrongifyAndReturnIfNil(self);
|
|
|
|
|
2019-03-07 09:08:39 +00:00
|
|
|
self->autoDiscovery = nil;
|
|
|
|
|
2019-03-06 17:30:03 +00:00
|
|
|
switch (discoveredClientConfig.action)
|
|
|
|
{
|
|
|
|
case MXDiscoveredClientConfigActionPrompt:
|
|
|
|
[self customiseServersWithWellKnown:discoveredClientConfig.wellKnown];
|
|
|
|
break;
|
|
|
|
|
|
|
|
case MXDiscoveredClientConfigActionFailPrompt:
|
|
|
|
case MXDiscoveredClientConfigActionFailError:
|
|
|
|
{
|
|
|
|
// Alert user
|
|
|
|
if (self->alert)
|
|
|
|
{
|
|
|
|
[self->alert dismissViewControllerAnimated:NO completion:nil];
|
|
|
|
}
|
|
|
|
|
2021-09-28 05:40:01 +00:00
|
|
|
self->alert = [UIAlertController alertControllerWithTitle:[VectorL10n authAutodiscoverInvalidResponse]
|
2019-03-06 17:30:03 +00:00
|
|
|
message:nil
|
|
|
|
preferredStyle:UIAlertControllerStyleAlert];
|
|
|
|
|
2021-09-28 05:40:01 +00:00
|
|
|
[self->alert addAction:[UIAlertAction actionWithTitle:[MatrixKitL10n ok]
|
2019-03-06 17:30:03 +00:00
|
|
|
style:UIAlertActionStyleDefault
|
|
|
|
handler:^(UIAlertAction * action) {
|
|
|
|
|
|
|
|
self->alert = nil;
|
|
|
|
}]];
|
|
|
|
|
|
|
|
[self presentViewController:self->alert animated:YES completion:nil];
|
|
|
|
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
default:
|
|
|
|
// Fail silently
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
} failure:^(NSError * _Nonnull error) {
|
2019-03-07 09:08:39 +00:00
|
|
|
MXStrongifyAndReturnIfNil(self);
|
|
|
|
|
|
|
|
self->autoDiscovery = nil;
|
|
|
|
|
2019-03-06 17:30:03 +00:00
|
|
|
// Fail silently
|
|
|
|
}];
|
|
|
|
}
|
|
|
|
|
|
|
|
- (void)customiseServersWithWellKnown:(MXWellKnown*)wellKnown
|
|
|
|
{
|
|
|
|
if (self.customServersContainer.hidden)
|
|
|
|
{
|
|
|
|
// Check wellKnown data with application default servers
|
|
|
|
// If different, use custom servers
|
|
|
|
if (![self.defaultHomeServerUrl isEqualToString:wellKnown.homeServer.baseUrl]
|
|
|
|
|| ![self.defaultIdentityServerUrl isEqualToString:wellKnown.identityServer.baseUrl])
|
|
|
|
{
|
|
|
|
[self showCustomHomeserver:wellKnown.homeServer.baseUrl andIdentityServer:wellKnown.identityServer.baseUrl];
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
if ([self.defaultHomeServerUrl isEqualToString:wellKnown.homeServer.baseUrl]
|
|
|
|
&& [self.defaultIdentityServerUrl isEqualToString:wellKnown.identityServer.baseUrl])
|
|
|
|
{
|
|
|
|
// wellKnown matches with application default servers
|
|
|
|
// Hide custom servers
|
|
|
|
[self hideCustomServers:YES];
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
NSString *customHomeServerURL = [[NSUserDefaults standardUserDefaults] objectForKey:@"customHomeServerURL"];
|
|
|
|
NSString *customIdentityServerURL = [[NSUserDefaults standardUserDefaults] objectForKey:@"customIdentityServerURL"];
|
|
|
|
|
|
|
|
if (![customHomeServerURL isEqualToString:wellKnown.homeServer.baseUrl]
|
|
|
|
|| ![customIdentityServerURL isEqualToString:wellKnown.identityServer.baseUrl])
|
|
|
|
{
|
|
|
|
// Update custom servers
|
|
|
|
[self showCustomHomeserver:wellKnown.homeServer.baseUrl andIdentityServer:wellKnown.identityServer.baseUrl];
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
- (void)showCustomHomeserver:(NSString*)homeserver andIdentityServer:(NSString*)identityServer
|
|
|
|
{
|
|
|
|
// Store the wellknown data into NSUserDefaults before displaying them
|
|
|
|
[[NSUserDefaults standardUserDefaults] setObject:homeserver forKey:@"customHomeServerURL"];
|
|
|
|
|
|
|
|
if (identityServer)
|
|
|
|
{
|
|
|
|
[[NSUserDefaults standardUserDefaults] setObject:identityServer forKey:@"customIdentityServerURL"];
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
[[NSUserDefaults standardUserDefaults] removeObjectForKey:@"customIdentityServerURL"];
|
|
|
|
}
|
|
|
|
|
|
|
|
// And show custom servers
|
|
|
|
[self hideCustomServers:NO];
|
|
|
|
}
|
|
|
|
|
2020-04-03 14:30:06 +00:00
|
|
|
#pragma mark - KeyVerificationCoordinatorBridgePresenterDelegate
|
|
|
|
|
2020-04-14 10:50:53 +00:00
|
|
|
- (void)keyVerificationCoordinatorBridgePresenterDelegateDidComplete:(KeyVerificationCoordinatorBridgePresenter * _Nonnull)coordinatorBridgePresenter otherUserId:(NSString * _Nonnull)otherUserId otherDeviceId:(NSString * _Nonnull)otherDeviceId
|
|
|
|
{
|
2021-02-01 08:53:17 +00:00
|
|
|
MXCrypto *crypto = coordinatorBridgePresenter.session.crypto;
|
|
|
|
if (!crypto.backup.hasPrivateKeyInCryptoStore || !crypto.backup.enabled)
|
|
|
|
{
|
2021-06-03 08:30:07 +00:00
|
|
|
MXLogDebug(@"[AuthenticationVC][MXKeyVerification] requestAllPrivateKeys: Request key backup private keys");
|
2021-02-01 08:53:17 +00:00
|
|
|
[crypto setOutgoingKeyRequestsEnabled:YES onComplete:nil];
|
|
|
|
}
|
2020-04-14 10:50:53 +00:00
|
|
|
[self dismiss];
|
|
|
|
}
|
|
|
|
|
|
|
|
- (void)keyVerificationCoordinatorBridgePresenterDelegateDidCancel:(KeyVerificationCoordinatorBridgePresenter * _Nonnull)coordinatorBridgePresenter
|
|
|
|
{
|
2020-04-03 14:30:06 +00:00
|
|
|
[self dismiss];
|
|
|
|
}
|
|
|
|
|
2020-07-17 16:03:00 +00:00
|
|
|
#pragma mark - SetPinCoordinatorBridgePresenterDelegate
|
|
|
|
|
|
|
|
- (void)setPinCoordinatorBridgePresenterDelegateDidComplete:(SetPinCoordinatorBridgePresenter *)coordinatorBridgePresenter
|
|
|
|
{
|
2020-09-14 19:06:12 +00:00
|
|
|
[coordinatorBridgePresenter dismissWithAnimated:YES completion:nil];
|
|
|
|
self.setPinCoordinatorBridgePresenter = nil;
|
2020-07-17 16:03:00 +00:00
|
|
|
|
|
|
|
[self afterSetPinFlowCompletedWithCredentials:loginCredentials];
|
|
|
|
}
|
|
|
|
|
2020-07-21 13:14:46 +00:00
|
|
|
- (void)setPinCoordinatorBridgePresenterDelegateDidCancel:(SetPinCoordinatorBridgePresenter *)coordinatorBridgePresenter
|
|
|
|
{
|
|
|
|
// enable the view again
|
|
|
|
[self setUserInteractionEnabled:YES];
|
|
|
|
|
|
|
|
// stop the spinner
|
|
|
|
[self.authenticationActivityIndicator stopAnimating];
|
|
|
|
|
|
|
|
// then, just close the enter pin screen
|
|
|
|
[coordinatorBridgePresenter dismissWithAnimated:YES completion:nil];
|
2020-09-14 19:06:12 +00:00
|
|
|
self.setPinCoordinatorBridgePresenter = nil;
|
2020-07-21 13:14:46 +00:00
|
|
|
}
|
|
|
|
|
2020-12-17 16:39:33 +00:00
|
|
|
#pragma mark - Social login view management
|
|
|
|
|
|
|
|
- (BOOL)isSocialLoginViewShown
|
|
|
|
{
|
|
|
|
return self.socialLoginListView.superview
|
|
|
|
&& !self.socialLoginListView.isHidden
|
|
|
|
&& self.currentLoginSSOFlow.identityProviders.count;
|
|
|
|
}
|
|
|
|
|
|
|
|
- (CGFloat)socialLoginViewHeightFittingWidth:(CGFloat)width
|
|
|
|
{
|
|
|
|
NSArray<MXLoginSSOIdentityProvider*> *identityProviders = self.currentLoginSSOFlow.identityProviders;
|
|
|
|
|
|
|
|
if (!identityProviders.count && self.socialLoginListView)
|
|
|
|
{
|
|
|
|
return 0.0;
|
|
|
|
}
|
|
|
|
|
|
|
|
return [SocialLoginListView contentViewHeightWithIdentityProviders:identityProviders mode:self.socialLoginListView.mode fitting:self.contentView.frame.size.width];
|
|
|
|
}
|
|
|
|
|
|
|
|
- (void)showSocialLoginViewWithLoginSSOFlow:(MXLoginSSOFlow*)loginSSOFlow andMode:(SocialLoginButtonMode)mode
|
|
|
|
{
|
|
|
|
SocialLoginListView *listView = self.socialLoginListView;
|
|
|
|
|
|
|
|
if (!listView)
|
|
|
|
{
|
|
|
|
listView = [SocialLoginListView instantiate];
|
|
|
|
[self.socialLoginContainerView vc_addSubViewMatchingParent:listView];
|
|
|
|
self.socialLoginListView = listView;
|
|
|
|
listView.delegate = self;
|
|
|
|
}
|
|
|
|
|
|
|
|
[listView updateWith:loginSSOFlow.identityProviders mode:mode];
|
|
|
|
|
|
|
|
[self refreshContentViewHeightConstraint];
|
|
|
|
}
|
|
|
|
|
|
|
|
- (void)hideSocialLoginView
|
|
|
|
{
|
|
|
|
[self.socialLoginListView removeFromSuperview];
|
|
|
|
[self refreshContentViewHeightConstraint];
|
|
|
|
}
|
|
|
|
|
|
|
|
- (void)updateSocialLoginViewVisibility
|
|
|
|
{
|
|
|
|
SocialLoginButtonMode socialLoginButtonMode = SocialLoginButtonModeContinue;
|
|
|
|
|
|
|
|
BOOL showSocialLoginView = self.currentLoginSSOFlow ? YES : NO;
|
|
|
|
|
|
|
|
switch (self.authType)
|
|
|
|
{
|
|
|
|
case MXKAuthenticationTypeForgotPassword:
|
|
|
|
showSocialLoginView = NO;
|
|
|
|
break;
|
|
|
|
case MXKAuthenticationTypeRegister:
|
|
|
|
socialLoginButtonMode = SocialLoginButtonModeSignUp;
|
|
|
|
break;
|
|
|
|
case MXKAuthenticationTypeLogin:
|
|
|
|
if (((AuthInputsView*)self.authInputsView).isSingleSignOnRequired)
|
|
|
|
{
|
|
|
|
socialLoginButtonMode = SocialLoginButtonModeContinue;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
socialLoginButtonMode = SocialLoginButtonModeSignIn;
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (showSocialLoginView)
|
|
|
|
{
|
|
|
|
[self showSocialLoginViewWithLoginSSOFlow:self.currentLoginSSOFlow andMode:socialLoginButtonMode];
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
[self hideSocialLoginView];
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
#pragma mark - SocialLoginListViewDelegate
|
|
|
|
|
|
|
|
- (void)socialLoginListView:(SocialLoginListView *)socialLoginListView didTapSocialButtonWithIdentifier:(NSString *)identifier
|
|
|
|
{
|
2020-12-18 17:31:04 +00:00
|
|
|
[self presentSSOAuthenticationForIdentityProviderIdentifier:identifier];
|
|
|
|
}
|
|
|
|
|
|
|
|
#pragma mark - SSOIdentityProviderAuthenticationPresenter
|
|
|
|
|
|
|
|
- (void)presentSSOAuthenticationForIdentityProviderIdentifier:(NSString*)identityProviderIdentifier
|
|
|
|
{
|
|
|
|
NSString *homeServerStringURL = self.homeServerTextField.text;
|
|
|
|
|
|
|
|
if (!homeServerStringURL)
|
|
|
|
{
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
SSOAuthenticationService *ssoAuthenticationService = [[SSOAuthenticationService alloc] initWithHomeserverStringURL:homeServerStringURL];
|
|
|
|
|
|
|
|
SSOAuthenticationPresenter *presenter = [[SSOAuthenticationPresenter alloc] initWithSsoAuthenticationService:ssoAuthenticationService];
|
|
|
|
|
|
|
|
presenter.delegate = self;
|
|
|
|
|
2021-01-07 13:38:27 +00:00
|
|
|
// Generate a unique identifier that will identify the success callback URL
|
|
|
|
NSString *transactionId = [MXTools generateTransactionId];
|
|
|
|
|
|
|
|
[presenter presentForIdentityProviderIdentifier:identityProviderIdentifier with: transactionId from:self animated:YES];
|
|
|
|
|
|
|
|
self.ssoCallbackTxnId = transactionId;
|
2020-12-18 17:31:04 +00:00
|
|
|
self.ssoAuthenticationPresenter = presenter;
|
|
|
|
}
|
|
|
|
|
|
|
|
- (void)presentDefaultSSOAuthentication
|
|
|
|
{
|
|
|
|
[self presentSSOAuthenticationForIdentityProviderIdentifier:nil];
|
|
|
|
}
|
|
|
|
|
|
|
|
- (void)dismissSSOAuthenticationPresenter
|
|
|
|
{
|
|
|
|
[self.ssoAuthenticationPresenter dismissWithAnimated:YES completion:nil];
|
|
|
|
self.ssoAuthenticationPresenter = nil;
|
|
|
|
}
|
|
|
|
|
|
|
|
// TODO: Move to SDK
|
|
|
|
- (void)loginWithToken:(NSString*)loginToken
|
|
|
|
{
|
|
|
|
NSDictionary *parameters = @{
|
|
|
|
@"type" : kMXLoginFlowTypeToken,
|
|
|
|
@"token": loginToken
|
|
|
|
};
|
|
|
|
|
|
|
|
[self loginWithParameters:parameters];
|
|
|
|
}
|
|
|
|
|
|
|
|
#pragma mark - SSOAuthenticationPresenterDelegate
|
|
|
|
|
|
|
|
- (void)ssoAuthenticationPresenterDidCancel:(SSOAuthenticationPresenter *)presenter
|
|
|
|
{
|
|
|
|
[self dismissSSOAuthenticationPresenter];
|
|
|
|
}
|
|
|
|
|
|
|
|
- (void)ssoAuthenticationPresenter:(SSOAuthenticationPresenter *)presenter authenticationDidFailWithError:(NSError *)error
|
|
|
|
{
|
|
|
|
[self dismissSSOAuthenticationPresenter];
|
2021-06-28 14:45:20 +00:00
|
|
|
[self.errorPresenter presentErrorFromViewController:self forError:error animated:YES handler:nil];
|
2020-12-18 17:31:04 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
- (void)ssoAuthenticationPresenter:(SSOAuthenticationPresenter *)presenter authenticationSucceededWithToken:(NSString *)token
|
|
|
|
{
|
|
|
|
[self dismissSSOAuthenticationPresenter];
|
|
|
|
[self loginWithToken:token];
|
2020-12-17 16:39:33 +00:00
|
|
|
}
|
|
|
|
|
2014-10-08 12:14:12 +00:00
|
|
|
@end
|