mirror of
https://github.com/bitwarden/mobile.git
synced 2024-12-28 17:18:23 +01:00
Show vault export warning as popup (#1185)
This commit is contained in:
parent
e0191c573d
commit
217514af66
@ -76,19 +76,6 @@
|
|||||||
<Label
|
<Label
|
||||||
Text="{u:I18n ExportVaultMasterPasswordDescription}"
|
Text="{u:I18n ExportVaultMasterPasswordDescription}"
|
||||||
StyleClass="box-footer-label, box-footer-label-switch" />
|
StyleClass="box-footer-label, box-footer-label-switch" />
|
||||||
<Label
|
|
||||||
StyleClass="box-footer-label, box-footer-label-switch"
|
|
||||||
Margin="0, 20">
|
|
||||||
<Label.FormattedText>
|
|
||||||
<FormattedString>
|
|
||||||
<Span
|
|
||||||
Text="{Binding Converter={StaticResource toUpper}, ConverterParameter={u:I18n Warning}}"
|
|
||||||
FontAttributes="Bold" />
|
|
||||||
<Span Text=": " FontAttributes="Bold" />
|
|
||||||
<Span Text="{Binding ExportWarningMessage}" />
|
|
||||||
</FormattedString>
|
|
||||||
</Label.FormattedText>
|
|
||||||
</Label>
|
|
||||||
<StackLayout Spacing="20">
|
<StackLayout Spacing="20">
|
||||||
<Button Text="{u:I18n ExportVault}"
|
<Button Text="{u:I18n ExportVault}"
|
||||||
Clicked="ExportVault_Clicked"
|
Clicked="ExportVault_Clicked"
|
||||||
|
@ -105,36 +105,43 @@ namespace Bit.App.Pages
|
|||||||
|
|
||||||
var keyHash = await _cryptoService.HashPasswordAsync(_masterPassword, null);
|
var keyHash = await _cryptoService.HashPasswordAsync(_masterPassword, null);
|
||||||
MasterPassword = string.Empty;
|
MasterPassword = string.Empty;
|
||||||
|
|
||||||
var storedKeyHash = await _cryptoService.GetKeyHashAsync();
|
|
||||||
if (storedKeyHash != null && keyHash != null && storedKeyHash == keyHash)
|
|
||||||
{
|
|
||||||
try
|
|
||||||
{
|
|
||||||
var data = await _exportService.GetExport(FileFormatOptions[FileFormatSelectedIndex].Key);
|
|
||||||
var fileFormat = FileFormatOptions[FileFormatSelectedIndex].Key;
|
|
||||||
_defaultFilename = _exportService.GetFileName(null, fileFormat);
|
|
||||||
_exportResult = Encoding.ASCII.GetBytes(data);
|
|
||||||
|
|
||||||
if (!_deviceActionService.SaveFile(_exportResult, null, _defaultFilename, null))
|
var storedKeyHash = await _cryptoService.GetKeyHashAsync();
|
||||||
{
|
if (storedKeyHash == null || keyHash == null || storedKeyHash != keyHash)
|
||||||
ClearResult();
|
{
|
||||||
await _platformUtilsService.ShowDialogAsync(_i18nService.T("ExportVaultFailure"));
|
await _platformUtilsService.ShowDialogAsync(_i18nService.T("InvalidMasterPassword"));
|
||||||
}
|
return;
|
||||||
}
|
}
|
||||||
catch (Exception ex)
|
|
||||||
|
bool userConfirmedExport = await _platformUtilsService.ShowDialogAsync(ExportWarningMessage,
|
||||||
|
_i18nService.T("ExportVaultConfirmationTitle"), _i18nService.T("ExportVault"), _i18nService.T("Cancel"));
|
||||||
|
|
||||||
|
if (!userConfirmedExport)
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
try
|
||||||
|
{
|
||||||
|
var data = await _exportService.GetExport(FileFormatOptions[FileFormatSelectedIndex].Key);
|
||||||
|
var fileFormat = FileFormatOptions[FileFormatSelectedIndex].Key;
|
||||||
|
_defaultFilename = _exportService.GetFileName(null, fileFormat);
|
||||||
|
_exportResult = Encoding.ASCII.GetBytes(data);
|
||||||
|
|
||||||
|
if (!_deviceActionService.SaveFile(_exportResult, null, _defaultFilename, null))
|
||||||
{
|
{
|
||||||
ClearResult();
|
ClearResult();
|
||||||
await _platformUtilsService.ShowDialogAsync(_i18nService.T("ExportVaultFailure"));
|
await _platformUtilsService.ShowDialogAsync(_i18nService.T("ExportVaultFailure"));
|
||||||
System.Diagnostics.Debug.WriteLine(">>> {0}: {1}", ex.GetType(), ex.StackTrace);
|
|
||||||
#if !FDROID
|
|
||||||
Crashes.TrackError(ex);
|
|
||||||
#endif
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else
|
catch (Exception ex)
|
||||||
{
|
{
|
||||||
await _platformUtilsService.ShowDialogAsync(_i18nService.T("InvalidMasterPassword"));
|
ClearResult();
|
||||||
|
await _platformUtilsService.ShowDialogAsync(_i18nService.T("ExportVaultFailure"));
|
||||||
|
System.Diagnostics.Debug.WriteLine(">>> {0}: {1}", ex.GetType(), ex.StackTrace);
|
||||||
|
#if !FDROID
|
||||||
|
Crashes.TrackError(ex);
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
8
src/App/Resources/AppResources.Designer.cs
generated
8
src/App/Resources/AppResources.Designer.cs
generated
@ -2827,6 +2827,14 @@ namespace Bit.App.Resources {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static string ExportVaultConfirmationTitle
|
||||||
|
{
|
||||||
|
get
|
||||||
|
{
|
||||||
|
return ResourceManager.GetString("ExportVaultConfirmationTitle", resourceCulture);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
public static string Warning {
|
public static string Warning {
|
||||||
get {
|
get {
|
||||||
return ResourceManager.GetString("Warning", resourceCulture);
|
return ResourceManager.GetString("Warning", resourceCulture);
|
||||||
|
@ -1605,6 +1605,10 @@
|
|||||||
<data name="EncExportVaultWarning" xml:space="preserve">
|
<data name="EncExportVaultWarning" xml:space="preserve">
|
||||||
<value>This export encrypts your data using your account's encryption key. If you ever rotate your account's encryption key you should export again since you will not be able to decrypt this export file.</value>
|
<value>This export encrypts your data using your account's encryption key. If you ever rotate your account's encryption key you should export again since you will not be able to decrypt this export file.</value>
|
||||||
</data>
|
</data>
|
||||||
|
<data name="ExportVaultConfirmationTitle" xml:space="preserve">
|
||||||
|
<value>Confirm Vault Export</value>
|
||||||
|
<comment>Title for the alert to confirm vault exports.</comment>
|
||||||
|
</data>
|
||||||
<data name="Warning" xml:space="preserve">
|
<data name="Warning" xml:space="preserve">
|
||||||
<value>Warning</value>
|
<value>Warning</value>
|
||||||
</data>
|
</data>
|
||||||
@ -1792,4 +1796,4 @@
|
|||||||
<data name="PersonalOwnershipSubmitError" xml:space="preserve">
|
<data name="PersonalOwnershipSubmitError" xml:space="preserve">
|
||||||
<value>Due to an Enterprise Policy, you are restricted from saving items to your personal vault. Change the Ownership option to an organization and choose from available Collections.</value>
|
<value>Due to an Enterprise Policy, you are restricted from saving items to your personal vault. Change the Ownership option to an organization and choose from available Collections.</value>
|
||||||
</data>
|
</data>
|
||||||
</root>
|
</root>
|
||||||
|
Loading…
Reference in New Issue
Block a user