mirror of
https://github.com/bitwarden/android.git
synced 2024-12-27 03:18:27 +03:00
[SG-690] Login Request does not disappear after 15 minutes (#2106)
* [SG-690] Add timeout of 15 for android notifications. Add condition to not prompt login requests if 15mins have passed. Add constant for timeout time. * [SG-690] Added dialog on click confirm/deny if the request is expired. * [SG-690] PR fixes * [SG-690] PR fixes
This commit is contained in:
parent
9631988fc2
commit
90e0b5dcf0
6 changed files with 6618 additions and 4386 deletions
|
@ -74,7 +74,6 @@ namespace Bit.Droid.Services
|
||||||
throw new ArgumentNullException("notificationId cannot be null or empty.");
|
throw new ArgumentNullException("notificationId cannot be null or empty.");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
var context = Android.App.Application.Context;
|
var context = Android.App.Application.Context;
|
||||||
var intent = new Intent(context, typeof(MainActivity));
|
var intent = new Intent(context, typeof(MainActivity));
|
||||||
var pendingIntentFlags = AndroidHelpers.AddPendingIntentMutabilityFlag(PendingIntentFlags.UpdateCurrent, true);
|
var pendingIntentFlags = AndroidHelpers.AddPendingIntentMutabilityFlag(PendingIntentFlags.UpdateCurrent, true);
|
||||||
|
@ -83,6 +82,7 @@ namespace Bit.Droid.Services
|
||||||
.SetContentIntent(pendingIntent)
|
.SetContentIntent(pendingIntent)
|
||||||
.SetContentTitle(title)
|
.SetContentTitle(title)
|
||||||
.SetContentText(message)
|
.SetContentText(message)
|
||||||
|
.SetTimeoutAfter(Constants.PasswordlessNotificationTimeoutInMinutes * 60000)
|
||||||
.SetSmallIcon(Resource.Drawable.ic_notification)
|
.SetSmallIcon(Resource.Drawable.ic_notification)
|
||||||
.SetColor((int)Android.Graphics.Color.White)
|
.SetColor((int)Android.Graphics.Color.White)
|
||||||
.SetAutoCancel(true);
|
.SetAutoCancel(true);
|
||||||
|
|
|
@ -189,7 +189,10 @@ namespace Bit.App
|
||||||
});
|
});
|
||||||
await _stateService.SetPasswordlessLoginNotificationAsync(null);
|
await _stateService.SetPasswordlessLoginNotificationAsync(null);
|
||||||
_pushNotificationService.DismissLocalNotification(Constants.PasswordlessNotificationId);
|
_pushNotificationService.DismissLocalNotification(Constants.PasswordlessNotificationId);
|
||||||
await Device.InvokeOnMainThreadAsync(async () => await Application.Current.MainPage.Navigation.PushModalAsync(new NavigationPage(page)));
|
if (loginRequestData.CreationDate.AddMinutes(Constants.PasswordlessNotificationTimeoutInMinutes) > DateTime.Now)
|
||||||
|
{
|
||||||
|
await Device.InvokeOnMainThreadAsync(() => Application.Current.MainPage.Navigation.PushModalAsync(new NavigationPage(page)));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public AppOptions Options { get; private set; }
|
public AppOptions Options { get; private set; }
|
||||||
|
|
|
@ -65,6 +65,13 @@ namespace Bit.App.Pages
|
||||||
|
|
||||||
private async Task PasswordlessLoginAsync(bool approveRequest)
|
private async Task PasswordlessLoginAsync(bool approveRequest)
|
||||||
{
|
{
|
||||||
|
if (LoginRequest.RequestDate.AddMinutes(Constants.PasswordlessNotificationTimeoutInMinutes) <= DateTime.Now)
|
||||||
|
{
|
||||||
|
await _platformUtilsService.ShowDialogAsync(AppResources.LoginRequestHasAlreadyExpired);
|
||||||
|
await Page.Navigation.PopModalAsync();
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
await _deviceActionService.ShowLoadingAsync(AppResources.Loading);
|
await _deviceActionService.ShowLoadingAsync(AppResources.Loading);
|
||||||
await _authService.PasswordlessLoginAsync(LoginRequest.Id, LoginRequest.PubKey, approveRequest);
|
await _authService.PasswordlessLoginAsync(LoginRequest.Id, LoginRequest.PubKey, approveRequest);
|
||||||
await _deviceActionService.HideLoadingAsync();
|
await _deviceActionService.HideLoadingAsync();
|
||||||
|
|
10984
src/App/Resources/AppResources.Designer.cs
generated
10984
src/App/Resources/AppResources.Designer.cs
generated
File diff suppressed because it is too large
Load diff
|
@ -2461,4 +2461,7 @@ select Add TOTP to store the key safely</value>
|
||||||
<data name="Decline" xml:space="preserve">
|
<data name="Decline" xml:space="preserve">
|
||||||
<value>Decline</value>
|
<value>Decline</value>
|
||||||
</data>
|
</data>
|
||||||
|
<data name="LoginRequestHasAlreadyExpired" xml:space="preserve">
|
||||||
|
<value>Login request has already expired.</value>
|
||||||
|
</data>
|
||||||
</root>
|
</root>
|
||||||
|
|
|
@ -36,6 +36,7 @@
|
||||||
public const int SelectFilePermissionRequestCode = 43;
|
public const int SelectFilePermissionRequestCode = 43;
|
||||||
public const int SaveFileRequestCode = 44;
|
public const int SaveFileRequestCode = 44;
|
||||||
public const int TotpDefaultTimer = 30;
|
public const int TotpDefaultTimer = 30;
|
||||||
|
public const int PasswordlessNotificationTimeoutInMinutes = 15;
|
||||||
|
|
||||||
public static readonly string[] AndroidAllClearCipherCacheKeys =
|
public static readonly string[] AndroidAllClearCipherCacheKeys =
|
||||||
{
|
{
|
||||||
|
|
Loading…
Reference in a new issue