mirror of
https://github.com/bitwarden/mobile
synced 2025-12-19 09:43:27 +00:00
[SG-471] Added mock services. Added Accept/reject command binding, navigation and toast messages.
This commit is contained in:
@@ -77,10 +77,12 @@
|
||||
Margin="0,0,0,57"/>
|
||||
<Button
|
||||
Text="{u:I18n ConfirmLogIn}"
|
||||
Command="{Binding AcceptRequestCommand}"
|
||||
Margin="0,0,0,17"
|
||||
StyleClass="btn-primary"/>
|
||||
<Button
|
||||
Text="{u:I18n DenyLogIn}"
|
||||
Command="{Binding RejectRequestCommand}"
|
||||
StyleClass="btn-secundary"/>
|
||||
</StackLayout>
|
||||
</ScrollView>
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
using System;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace Bit.App.Pages
|
||||
{
|
||||
@@ -20,6 +21,11 @@ namespace Bit.App.Pages
|
||||
}
|
||||
|
||||
private async void Close_Clicked(object sender, System.EventArgs e)
|
||||
{
|
||||
await Close();
|
||||
}
|
||||
|
||||
public async Task Close()
|
||||
{
|
||||
if (DoOnce())
|
||||
{
|
||||
|
||||
@@ -6,12 +6,16 @@ using Bit.Core.Utilities;
|
||||
using Xamarin.Forms;
|
||||
using Bit.App.Utilities;
|
||||
using System.Linq;
|
||||
using Xamarin.CommunityToolkit.ObjectModel;
|
||||
using System.Windows.Input;
|
||||
|
||||
namespace Bit.App.Pages
|
||||
{
|
||||
public class LoginPasswordlessViewModel : BaseViewModel
|
||||
{
|
||||
private IStateService _stateService;
|
||||
private IAuthService _authService;
|
||||
private IPlatformUtilsService _platformUtilsService;
|
||||
private ILogger _logger;
|
||||
private string _logInAttempByLabel;
|
||||
private string _deviceType;
|
||||
private FormattedString _fingerprintPhraseFormatted;
|
||||
@@ -24,10 +28,24 @@ namespace Bit.App.Pages
|
||||
|
||||
public LoginPasswordlessViewModel()
|
||||
{
|
||||
_stateService = ServiceContainer.Resolve<IStateService>("stateService");
|
||||
_authService = ServiceContainer.Resolve<IAuthService>("authService");
|
||||
_platformUtilsService = ServiceContainer.Resolve<IPlatformUtilsService>("platformUtilsService");
|
||||
_logger = ServiceContainer.Resolve<ILogger>("logger");
|
||||
|
||||
PageTitle = AppResources.LogInRequested;
|
||||
|
||||
AcceptRequestCommand = new AsyncCommand(AcceptRequestAsync,
|
||||
onException: ex => _logger.Exception(ex),
|
||||
allowsMultipleExecutions: false);
|
||||
RejectRequestCommand = new AsyncCommand(RejectRequestAsync,
|
||||
onException: ex => _logger.Exception(ex),
|
||||
allowsMultipleExecutions: false);
|
||||
}
|
||||
|
||||
public ICommand AcceptRequestCommand { get; }
|
||||
|
||||
public ICommand RejectRequestCommand { get; }
|
||||
|
||||
public string Email
|
||||
{
|
||||
get => _email;
|
||||
@@ -139,5 +157,33 @@ namespace Bit.App.Pages
|
||||
|
||||
return RequestDate.ToShortTimeString();
|
||||
}
|
||||
|
||||
private async Task AcceptRequestAsync()
|
||||
{
|
||||
try
|
||||
{
|
||||
var res = await _authService.LogInPasswordlessAcceptAsync();
|
||||
await ((LoginPasswordlessPage)this.Page).Close();
|
||||
_platformUtilsService.ShowToast("info", null, AppResources.LogInAccepted);
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
_logger.Exception(ex);
|
||||
}
|
||||
}
|
||||
|
||||
private async Task RejectRequestAsync()
|
||||
{
|
||||
try
|
||||
{
|
||||
var res = await _authService.LogInPasswordlessRejectAsync();
|
||||
await ((LoginPasswordlessPage)this.Page).Close();
|
||||
_platformUtilsService.ShowToast("info", null, AppResources.LogInDenied);
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
_logger.Exception(ex);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
12
src/App/Resources/AppResources.Designer.cs
generated
12
src/App/Resources/AppResources.Designer.cs
generated
@@ -4132,5 +4132,17 @@ namespace Bit.App.Resources {
|
||||
return ResourceManager.GetString("MinutesAgo", resourceCulture);
|
||||
}
|
||||
}
|
||||
|
||||
public static string LogInAccepted {
|
||||
get {
|
||||
return ResourceManager.GetString("LogInAccepted", resourceCulture);
|
||||
}
|
||||
}
|
||||
|
||||
public static string LogInDenied {
|
||||
get {
|
||||
return ResourceManager.GetString("LogInDenied", resourceCulture);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -2305,4 +2305,10 @@
|
||||
<data name="MinutesAgo" xml:space="preserve">
|
||||
<value>minutes ago</value>
|
||||
</data>
|
||||
<data name="LogInAccepted" xml:space="preserve">
|
||||
<value>Log in accepted</value>
|
||||
</data>
|
||||
<data name="LogInDenied" xml:space="preserve">
|
||||
<value>Log in denied</value>
|
||||
</data>
|
||||
</root>
|
||||
|
||||
@@ -25,6 +25,11 @@ namespace Bit.Core.Abstractions
|
||||
Task<AuthResult> LogInSsoAsync(string code, string codeVerifier, string redirectUrl, string orgId);
|
||||
Task<AuthResult> LogInCompleteAsync(string email, string masterPassword, TwoFactorProviderType twoFactorProvider, string twoFactorToken, bool? remember = null);
|
||||
Task<AuthResult> LogInTwoFactorAsync(TwoFactorProviderType twoFactorProvider, string twoFactorToken, string captchaToken, bool? remember = null);
|
||||
|
||||
Task<AuthResult> GetLogInPasswordlessRequestsAsync();
|
||||
Task<AuthResult> LogInPasswordlessAcceptAsync();
|
||||
Task<AuthResult> LogInPasswordlessRejectAsync();
|
||||
|
||||
void LogOut(Action callback);
|
||||
void Init();
|
||||
}
|
||||
|
||||
@@ -468,5 +468,9 @@ namespace Bit.Core.Services
|
||||
TwoFactorProvidersData = null;
|
||||
SelectedTwoFactorProviderType = null;
|
||||
}
|
||||
|
||||
public async Task<AuthResult> GetLogInPasswordlessRequestsAsync() => await Task.FromResult<AuthResult>(new AuthResult());
|
||||
public async Task<AuthResult> LogInPasswordlessAcceptAsync() => await Task.FromResult<AuthResult>(new AuthResult());
|
||||
public async Task<AuthResult> LogInPasswordlessRejectAsync() => await Task.FromResult<AuthResult>(new AuthResult());
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user