Commit b03802b5 authored by atraczyk's avatar atraczyk Committed by Adrien Béraud

accounts: allow user to create account with no password

Change-Id: Id02be53bb9eb9c4f49425eacc5af4a1f25277972
parent 4ad3df9f
......@@ -41,6 +41,7 @@ public:
property Account^ _account;
property bool _hasArchivePassword;
property bool _editionMode;
property bool _disconnected;
......
......@@ -115,6 +115,10 @@ RingD::parseAccountDetails(const AccountDetailsBlob& allAccountDetails)
auto deviceId = accountDetails.find(DRing::Account::ConfProperties::RING_DEVICE_ID)->second;
auto deviceName = accountDetails.find(DRing::Account::ConfProperties::RING_DEVICE_NAME)->second;
auto hasArchivePassword = (accountDetails.find(DRing::Account::ConfProperties::ARCHIVE_HAS_PASSWORD)->second == ring::TRUE_STR)
? true
: false;
auto account = AccountsViewModel::instance->findItem(Utils::toPlatformString(accountId));
if (account) {
......@@ -192,6 +196,7 @@ RingD::parseAccountDetails(const AccountDetailsBlob& allAccountDetails)
dhtPublicInCalls,
turnEnabled,
turnAddress);
archive_has_password->Insert(Utils::toPlatformString(accountId), hasArchivePassword);
}
}
}
......@@ -1567,6 +1572,8 @@ RingD::startDaemon()
RingD::RingD()
{
archive_has_password = ref new Map<String^, bool>();
toaster = ToastNotificationManager::CreateToastNotifier();
NetworkInformation::NetworkStatusChanged += ref new NetworkStatusChangedEventHandler(this, &RingD::InternetConnectionChanged);
......
......@@ -269,6 +269,8 @@ internal: // why this property has to be internal and not public ?
event ShareRequested^ shareRequested;
event NameRegistered^ nameRegistered;
Map<String^, bool>^ archive_has_password;
private:
Vector<String^>^ callIdsList_;
......
......@@ -1355,6 +1355,10 @@
Text="&#xE8D7;" />
<TextBlock Text="Password" />
</StackPanel>
<ToggleSwitch x:Name="_usePasswordState_"
Margin="10,0,0,10"
IsOn="True"
Toggled="_usePasswordState__Toggled" />
<Grid Margin="10">
<Grid.ColumnDefinitions>
<ColumnDefinition Width="*" />
......
......@@ -334,7 +334,7 @@ void RingClientUWP::Views::SmartPanel::_addAccountBtn__Click(Platform::Object^ s
_accountCreationMenuScrollViewer_->ScrollToVerticalOffset(0);
_createAccountYes_->IsEnabled = false;
_usePasswordState_->IsOn = true;
_accountTypeComboBox_->SelectedIndex = 0;
_RegisterStateEdition_->IsOn = true;
_accountAliasTextBox_->Text = "";
......@@ -349,7 +349,7 @@ void RingClientUWP::Views::SmartPanel::_createAccountYes__Click(Platform::Object
case 0: /* RING account */
{
RingD::instance->createRINGAccount(_accountAliasTextBox_->Text
, _ringPasswordBoxAccountCreation_->Password
, _usePasswordState_->IsOn ? _ringPasswordBoxAccountCreation_->Password : ""
, true
, (_RegisterState_->IsOn) ? _usernameTextBox_->Text : "");
......@@ -605,6 +605,8 @@ SmartPanel::SmartPanelItem_Grid_PointerMoved(Platform::Object^ sender, Windows::
void RingClientUWP::Views::SmartPanel::checkStateAddAccountMenu()
{
bool usePassword = _usePasswordState_->IsOn;
bool isRingAccountType = (_accountTypeComboBox_->SelectedIndex == 0) ? true : false;
bool isAccountAlias = (_accountAliasTextBox_->Text->IsEmpty()) ? false : true;
......@@ -617,7 +619,7 @@ void RingClientUWP::Views::SmartPanel::checkStateAddAccountMenu()
_accountAliasInvalid_->Visibility = Windows::UI::Xaml::Visibility::Visible;
}
if (isRingAccountType) {
if (isRingAccountType && _ringPasswordBoxAccountCreation_) {
bool isPublic = _RegisterState_->IsOn;
bool isUsernameValid = (_usernameValid_->Visibility == Windows::UI::Xaml::Visibility::Visible
......@@ -630,22 +632,37 @@ void RingClientUWP::Views::SmartPanel::checkStateAddAccountMenu()
&& isPasswordValid)
? true : false;
if (isPasswordValid) {
_passwordValid_->Visibility = Windows::UI::Xaml::Visibility::Visible;
_passwordInvalid_->Visibility = Windows::UI::Xaml::Visibility::Collapsed;
}
else {
_passwordValid_->Visibility = Windows::UI::Xaml::Visibility::Collapsed;
_passwordInvalid_->Visibility = Windows::UI::Xaml::Visibility::Visible;
}
auto passwordValidation = ((isRingPasswordCheck && isPasswordValid) || !usePassword);
if (isRingPasswordCheck) {
_passwordCheckValid_->Visibility = Windows::UI::Xaml::Visibility::Visible;
if (!usePassword) {
_ringPasswordBoxAccountCreation_->IsEnabled = false;
_ringPasswordBoxAccountCreationCheck_->IsEnabled = false;
_passwordValid_->Visibility = Windows::UI::Xaml::Visibility::Collapsed;
_passwordInvalid_->Visibility = Windows::UI::Xaml::Visibility::Collapsed;
_passwordCheckValid_->Visibility = Windows::UI::Xaml::Visibility::Collapsed;
_passwordCheckInvalid_->Visibility = Windows::UI::Xaml::Visibility::Collapsed;
}
else {
_passwordCheckValid_->Visibility = Windows::UI::Xaml::Visibility::Collapsed;
_passwordCheckInvalid_->Visibility = Windows::UI::Xaml::Visibility::Visible;
_ringPasswordBoxAccountCreation_->IsEnabled = true;
_ringPasswordBoxAccountCreationCheck_->IsEnabled = true;
if (isPasswordValid) {
_passwordValid_->Visibility = Windows::UI::Xaml::Visibility::Visible;
_passwordInvalid_->Visibility = Windows::UI::Xaml::Visibility::Collapsed;
}
else {
_passwordValid_->Visibility = Windows::UI::Xaml::Visibility::Collapsed;
_passwordInvalid_->Visibility = Windows::UI::Xaml::Visibility::Visible;
}
if (isRingPasswordCheck) {
_passwordCheckValid_->Visibility = Windows::UI::Xaml::Visibility::Visible;
_passwordCheckInvalid_->Visibility = Windows::UI::Xaml::Visibility::Collapsed;
}
else {
_passwordCheckValid_->Visibility = Windows::UI::Xaml::Visibility::Collapsed;
_passwordCheckInvalid_->Visibility = Windows::UI::Xaml::Visibility::Visible;
}
}
if (isUsernameValid) {
......@@ -657,16 +674,17 @@ void RingClientUWP::Views::SmartPanel::checkStateAddAccountMenu()
}
if (isPublic)
if (isUsernameValid && isAccountAlias && isRingPasswordCheck && isPasswordValid)
if (isUsernameValid && isAccountAlias && passwordValidation)
_createAccountYes_->IsEnabled = true;
else
_createAccountYes_->IsEnabled = false;
else if (isAccountAlias && isRingPasswordCheck && isPasswordValid)
else if (isAccountAlias && passwordValidation)
_createAccountYes_->IsEnabled = true;
else
_createAccountYes_->IsEnabled = false;
} else {
}
else if (_createAccountYes_) {
if (isAccountAlias)
_createAccountYes_->IsEnabled = true;
else
......@@ -1269,6 +1287,12 @@ void RingClientUWP::Views::SmartPanel::_RegisterState__Toggled(Platform::Object^
checkStateAddAccountMenu();
}
void
SmartPanel::_usePasswordState__Toggled(Object^ sender, RoutedEventArgs^ e)
{
checkStateAddAccountMenu();
}
void RingClientUWP::Views::SmartPanel::_RegisterStateEdition__Toggled(Platform::Object^ sender, Windows::UI::Xaml::RoutedEventArgs^ e)
{
auto toggleSwitch = dynamic_cast<ToggleSwitch^>(sender);
......@@ -1802,7 +1826,14 @@ void RingClientUWP::Views::SmartPanel::_devicesMenuButton__Click(Platform::Objec
{
selectMenu(MenuOpen::DEVICE);
_pinGeneratorYes_->IsEnabled = false;
auto account = AccountListItemsViewModel::instance->_selectedItem->_account;
bool enablePasswordForPinGen = true;
if (RingD::instance->archive_has_password->HasKey(account->accountID_))
enablePasswordForPinGen = RingD::instance->archive_has_password->Lookup(account->accountID_);
_pinGeneratorYes_->IsEnabled = !enablePasswordForPinGen;
_passwordForPinGenerator_->IsEnabled = enablePasswordForPinGen;
_passwordForPinGenerator_->Password = "";
// refacto : do something better...
auto loader = ref new Windows::ApplicationModel::Resources::ResourceLoader();
......@@ -1811,7 +1842,6 @@ void RingClientUWP::Views::SmartPanel::_devicesMenuButton__Click(Platform::Objec
_waitingDevicesList_->Visibility = Windows::UI::Xaml::Visibility::Visible;
_devicesIdList_->Visibility = Windows::UI::Xaml::Visibility::Collapsed;
auto account = AccountListItemsViewModel::instance->_selectedItem->_account;
_deviceId_->Text = account->_deviceId;
_deviceName_->Text = account->_deviceName;
......
......@@ -170,6 +170,7 @@ private:
void _turnEnabledToggle__Toggled(Platform::Object^ sender, Windows::UI::Xaml::RoutedEventArgs^ e);
void _deleteAccountButton__Click(Platform::Object^ sender, Windows::UI::Xaml::RoutedEventArgs^ e);
void _removeContact_MenuFlyoutItem__Tapped(Platform::Object^ sender, Windows::UI::Xaml::Input::TappedRoutedEventArgs^ e);
void _usePasswordState__Toggled(Platform::Object^ sender, Windows::UI::Xaml::RoutedEventArgs^ e);
};
}
}
......@@ -167,7 +167,6 @@
<Setter Property="Background" Value="Transparent" />
<Setter Property="FontFamily" Value="Segoe MDL2 Assets" />
<Setter Property="Width" Value="80" />
<Setter Property="Width" Value="120" />
<Setter Property="FontSize" Value="70" />
<Setter Property="BorderThickness" Value="0" />
</Style>
......
......@@ -31,12 +31,12 @@
<Rectangle Height="50" />
<TextBlock x:Uid="_welcome_"
HorizontalAlignment="Center"
Style="{StaticResource HeaderTextBlockStyle}"
FontWeight="Normal"
FontSize="60"
Foreground="#FF535E5E">
FontWeight="Normal"
Foreground="#FF535E5E"
Style="{StaticResource HeaderTextBlockStyle}">
<TextBlock.RenderTransform>
<TranslateTransform X="0" Y="10"/>
<TranslateTransform X="0" Y="10" />
</TextBlock.RenderTransform>
</TextBlock>
<Image x:Name="_welcomeImage_"
......@@ -52,10 +52,10 @@
Visibility="Visible">
<TextBlock x:Name="_showCreateAccountMenuTitle_"
x:Uid="_wizardCreateAccountTitle_"
Padding="4"
HorizontalAlignment="Center"
FontSize="30"
Foreground="White"
Padding="4"
Style="{StaticResource SubheaderTextBlockStyle}"
Visibility="Collapsed" />
<Button x:Name="_showCreateAccountMenuBtn_"
......@@ -82,8 +82,8 @@
Padding="10,0"
Visibility="Visible">
<Button x:Name="_avatarWebcamCaptureBtn_"
Width="90"
Height="90"
Width="100"
Height="100"
Margin="0,10,0,0"
HorizontalAlignment="Center"
VerticalAlignment="Center"
......@@ -168,6 +168,10 @@
FontWeight="SemiLight"
Style="{StaticResource TitleTextBlockStyle}" />
</StackPanel>
<ToggleSwitch x:Name="_usePasswordState_"
Margin="10,0,0,10"
IsOn="True"
Toggled="_usePasswordState__Toggled" />
<Grid Margin="0,10">
<Grid.ColumnDefinitions>
<ColumnDefinition Width="*" />
......@@ -256,10 +260,10 @@
<StackPanel x:Name="addExistingAccountStep2">
<TextBlock x:Name="_showAddAccountMenuTitle_"
x:Uid="_wizardAddExistingAccountTitle_"
Padding="4"
HorizontalAlignment="Center"
FontSize="30"
Foreground="White"
Padding="4"
Style="{StaticResource SubheaderTextBlockStyle}"
Visibility="Collapsed" />
<Button x:Name="_showAddAccountMenuBtn_"
......
......@@ -75,6 +75,7 @@ Wizard::_createAccountYes__Click(Object^ sender, RoutedEventArgs^ e)
this->Dispatcher->RunAsync(Windows::UI::Core::CoreDispatcherPriority::High, ref new Windows::UI::Core::DispatchedHandler([this] () {
RingD::instance->isInWizard = false;
this->Frame->Navigate(Windows::UI::Xaml::Interop::TypeName(RingClientUWP::MainPage::typeid));
_password_->Password = usePassword ? _password_->Password : "";
RingD::instance->createRINGAccount(_fullnameTextBox_->Text
, _password_->Password
, true // upnp by default set to true
......@@ -120,8 +121,8 @@ Wizard::_avatarWebcamCaptureBtn__Click(Platform::Object^ sender, Windows::UI::Xa
if (auto bitmapImage = image.get()) {
auto brush = ref new ImageBrush();
auto circle = ref new Ellipse();
circle->Height = 100;
circle->Width = 100;
circle->Height = 80;
circle->Width = 80;
brush->ImageSource = bitmapImage;
circle->Fill = brush;
_avatarWebcamCaptureBtn_->Content = circle;
......@@ -182,7 +183,8 @@ void RingClientUWP::Views::Wizard::_password__PasswordChanged(Platform::Object^
checkState();
}
void RingClientUWP::Views::Wizard::_passwordCheck__PasswordChanged(Platform::Object^ sender, Windows::UI::Xaml::RoutedEventArgs^ e)
void
Wizard::_passwordCheck__PasswordChanged(Platform::Object^ sender, Windows::UI::Xaml::RoutedEventArgs^ e)
{
isPasswordsMatching = (_password_->Password
== _passwordCheck_->Password
......@@ -203,8 +205,13 @@ void RingClientUWP::Views::Wizard::_passwordCheck__PasswordChanged(Platform::Obj
void RingClientUWP::Views::Wizard::checkState()
{
if ((isPublic && isPasswordValid && isPasswordsMatching && isUsernameValid && isFullNameValid)
||(!isPublic && isPasswordValid && isPasswordsMatching && isFullNameValid))
if (!_password_)
return;
auto passwordValidation = ((isPasswordsMatching && isPasswordValid) || !usePassword);
if ((isPublic && passwordValidation && isUsernameValid && isFullNameValid)
|| (!isPublic && passwordValidation && isFullNameValid))
_createAccountYes_->IsEnabled = true;
else
_createAccountYes_->IsEnabled = false;
......@@ -333,3 +340,29 @@ Wizard::_createAccountNo__Click(Platform::Object^ sender, Windows::UI::Xaml::Rou
{
}
void
Wizard::_usePasswordState__Toggled(Platform::Object^ sender, Windows::UI::Xaml::RoutedEventArgs^ e)
{
if (!_password_)
return;
usePassword = _usePasswordState_->IsOn;
if (!usePassword) {
_password_->IsEnabled = false;
_passwordCheck_->IsEnabled = false;
_passwordValid_->Visibility = Windows::UI::Xaml::Visibility::Collapsed;
_passwordInvalid_->Visibility = Windows::UI::Xaml::Visibility::Collapsed;
_passwordCheckValid_->Visibility = Windows::UI::Xaml::Visibility::Collapsed;
_passwordCheckInvalid_->Visibility = Windows::UI::Xaml::Visibility::Collapsed;
}
else {
_password_->IsEnabled = true;
_passwordCheck_->IsEnabled = true;
_password__PasswordChanged(nullptr, nullptr);
_passwordCheck__PasswordChanged(nullptr, nullptr);
}
checkState();
}
......@@ -35,6 +35,13 @@ protected:
virtual void OnNavigatedTo(Windows::UI::Xaml::Navigation::NavigationEventArgs^ e) override;
private:
bool usePassword;
bool isPasswordValid;
bool isPasswordsMatching;
bool isPublic = true;
bool isUsernameValid; // available
bool isFullNameValid;
void _createAccountYes__Click(Platform::Object^ sender, Windows::UI::Xaml::RoutedEventArgs^ e);
void _showCreateAccountMenuBtn__Click(Platform::Object^ sender, Windows::UI::Xaml::RoutedEventArgs^ e);
void _showAddAccountMenuBtn__Click(Platform::Object^ sender, Windows::UI::Xaml::RoutedEventArgs^ e);
......@@ -48,18 +55,12 @@ private:
void _password__PasswordChanged(Platform::Object^ sender, Windows::UI::Xaml::RoutedEventArgs^ e);
void _passwordCheck__PasswordChanged(Platform::Object^ sender, Windows::UI::Xaml::RoutedEventArgs^ e);
void checkState();
/*members*/
bool isPasswordValid;
bool isPasswordsMatching;
bool isPublic = true;
bool isUsernameValid; // available
bool isFullNameValid;
void OnregistrationStateErrorGeneric(const std::string &accountId);
void _PINTextBox__GotFocus(Platform::Object^ sender, Windows::UI::Xaml::RoutedEventArgs^ e);
void _ArchivePassword__KeyUp(Platform::Object^ sender, Windows::UI::Xaml::Input::KeyRoutedEventArgs^ e);
void _PINTextBox__KeyUp(Platform::Object^ sender, Windows::UI::Xaml::Input::KeyRoutedEventArgs^ e);
void _createAccountNo__Click(Platform::Object^ sender, Windows::UI::Xaml::RoutedEventArgs^ e);
void _usePasswordState__Toggled(Platform::Object^ sender, Windows::UI::Xaml::RoutedEventArgs^ e);
};
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment