mirror of
https://gitlab.com/fabinfra/fabaccess/borepin.git
synced 2025-03-12 23:01:52 +01:00
Added: Change Password
This commit is contained in:
parent
3158295d6b
commit
64f5fe0a07
@ -3,7 +3,6 @@
|
||||
xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml"
|
||||
x:Class="Borepin.Page.ProfilePage"
|
||||
xmlns:converters="clr-namespace:Borepin.Converter"
|
||||
xmlns:views="clr-namespace:Borepin.View"
|
||||
xmlns:resource_text="clr-namespace:Borepin.Resources.Text"
|
||||
Title="{x:Static resource_text:TextResource.TITLE_Profile}">
|
||||
<ContentPage.Content>
|
||||
@ -14,6 +13,10 @@
|
||||
<StackLayout IsVisible="{Binding IsBusy, Converter={StaticResource InvertBoolConverter}}">
|
||||
<StackLayout IsVisible="{Binding IsConnected}">
|
||||
<Label Text="{Binding UserItem.Name}" Style="{StaticResource LabelStyle_Title}"/>
|
||||
<Label Text="{x:Static resource_text:TextResource.ProfilePage_ChangePassword}" Style="{StaticResource Style_Label_Property_Title}"/>
|
||||
<Entry Placeholder="{x:Static resource_text:TextResource.ProfilePage_OldPassword}" Text="{Binding OldPassword}"/>
|
||||
<Entry Placeholder="{x:Static resource_text:TextResource.ProfilePage_NewPassword}" Text="{Binding NewPassword}"/>
|
||||
<Button Text="{x:Static resource_text:TextResource.ProfilePage_UpdatePassword}" Command="{Binding UpdatePasswordCommand}" Style="{StaticResource Style_Button_Primary}"/>
|
||||
</StackLayout>
|
||||
<StackLayout IsVisible="{Binding IsConnected, Converter={StaticResource InvertBoolConverter}}">
|
||||
<Label Text="{x:Static resource_text:TextResource.PLEASECONNECTTOSERVER}"/>
|
||||
|
@ -31,6 +31,9 @@
|
||||
</DataTemplate>
|
||||
</ListView.ItemTemplate>
|
||||
</ListView>
|
||||
<Label Text="{x:Static resource_text:TextResource.UserPage_ChangePassword}" Style="{StaticResource Style_Label_Property_Title}"/>
|
||||
<Entry Placeholder="{x:Static resource_text:TextResource.UserPage_NewPassword}" Text="{Binding NewPassword}"/>
|
||||
<Button Text="{x:Static resource_text:TextResource.UserPage_UpdatePassword}" Command="{Binding UpdatePasswordCommand}" Style="{StaticResource Style_Button_Primary}"/>
|
||||
<Button Grid.Row="1" Text="{x:Static resource_text:TextResource.DELETE}" Command="{Binding DeleteCommand}" Style="{StaticResource Style_Button_Admin}" VerticalOptions="End"/>
|
||||
</StackLayout>
|
||||
<StackLayout IsVisible="{Binding IsConnected, Converter={StaticResource InvertBoolConverter}}">
|
||||
|
97
Borepin/Borepin/PageModel/ProfilePageModel.cs
Normal file
97
Borepin/Borepin/PageModel/ProfilePageModel.cs
Normal file
@ -0,0 +1,97 @@
|
||||
using Borepin.Base;
|
||||
using Prism.Commands;
|
||||
using Prism.Navigation;
|
||||
using System.Threading.Tasks;
|
||||
using System.Windows.Input;
|
||||
using FabAccessAPI.Schema;
|
||||
using Borepin.Model;
|
||||
using Prism.Services;
|
||||
using Borepin.Service;
|
||||
using Borepin.Base.Exceptions;
|
||||
using Capnp.Rpc;
|
||||
using System;
|
||||
using Borepin.ViewModel;
|
||||
using System.Collections.Generic;
|
||||
using NaturalSort.Extension;
|
||||
using System.Linq;
|
||||
using Prism.Services.Dialogs;
|
||||
using Xamarin.Forms;
|
||||
|
||||
namespace Borepin.PageModel
|
||||
{
|
||||
public class ProfilePageModel : ConnectionModelBase
|
||||
{
|
||||
#region Contructors
|
||||
public ProfilePageModel(INavigationService navigationService, IPageDialogService pageDialogService, IAPIService apiService) : base(navigationService, pageDialogService, apiService)
|
||||
{
|
||||
UpdatePasswordCommand = new DelegateCommand(UpdatePasswordCommandExecute);
|
||||
}
|
||||
#endregion
|
||||
|
||||
#region Data
|
||||
public override Task LoadInstance(object instance)
|
||||
{
|
||||
return Task.CompletedTask;
|
||||
}
|
||||
|
||||
public override async Task LoadAPIData()
|
||||
{
|
||||
_UserItem = new UserVisualize(await _API.Session.UserSystem.Info.GetUserSelf().ConfigureAwait(false));
|
||||
}
|
||||
#endregion
|
||||
|
||||
#region Fields
|
||||
|
||||
private UserVisualize _UserItem;
|
||||
public UserVisualize UserItem
|
||||
{
|
||||
get => _UserItem;
|
||||
set => SetProperty(ref _UserItem, value);
|
||||
}
|
||||
|
||||
private string _OldPassword = null;
|
||||
public string OldPassword
|
||||
{
|
||||
get => _OldPassword;
|
||||
set => SetProperty(ref _OldPassword, value);
|
||||
}
|
||||
|
||||
private string _NewPassword = null;
|
||||
public string NewPassword
|
||||
{
|
||||
get => _NewPassword;
|
||||
set => SetProperty(ref _NewPassword, value);
|
||||
}
|
||||
#endregion
|
||||
|
||||
#region Commands
|
||||
private ICommand _UpdatePasswordCommand;
|
||||
public ICommand UpdatePasswordCommand
|
||||
{
|
||||
get => _UpdatePasswordCommand;
|
||||
set => SetProperty(ref _UpdatePasswordCommand, value);
|
||||
}
|
||||
|
||||
public async void UpdatePasswordCommandExecute()
|
||||
{
|
||||
IsBusy = true;
|
||||
if (_API.IsConnected)
|
||||
{
|
||||
try
|
||||
{
|
||||
if(OldPassword != null && OldPassword != string.Empty && NewPassword != null && NewPassword != string.Empty)
|
||||
{
|
||||
User self = await _API.Session.UserSystem.Info.GetUserSelf().ConfigureAwait(false);
|
||||
await self.Manage.Pwd(OldPassword, NewPassword).ConfigureAwait(false);
|
||||
}
|
||||
}
|
||||
catch (RpcException exception) when (string.Equals(exception.Message, "RPC connection is broken. Task would never return.", StringComparison.Ordinal))
|
||||
{
|
||||
Log.Debug("RPC Connection Loss");
|
||||
}
|
||||
}
|
||||
IsBusy = false;
|
||||
}
|
||||
#endregion
|
||||
}
|
||||
}
|
@ -33,6 +33,7 @@ namespace Borepin.PageModel
|
||||
{
|
||||
_DialogService = dialogService;
|
||||
DeleteCommand = new DelegateCommand(DeleteCommandExecute);
|
||||
UpdatePasswordCommand = new DelegateCommand(UpdatePasswordCommandExecute);
|
||||
}
|
||||
#endregion
|
||||
|
||||
@ -120,6 +121,13 @@ namespace Borepin.PageModel
|
||||
get => _CanManage;
|
||||
set => SetProperty(ref _CanManage, value);
|
||||
}
|
||||
|
||||
private string _NewPassword;
|
||||
public string NewPassword
|
||||
{
|
||||
get => _NewPassword;
|
||||
set => SetProperty(ref _NewPassword, value);
|
||||
}
|
||||
#endregion
|
||||
|
||||
#region Commands
|
||||
@ -132,6 +140,8 @@ namespace Borepin.PageModel
|
||||
|
||||
public void DeleteCommandExecute()
|
||||
{
|
||||
_IsDialog = true;
|
||||
|
||||
DialogParameters parameters = new DialogParameters
|
||||
{
|
||||
{ "title", Resources.Text.TextResource.DIALOG_DeleteUser },
|
||||
@ -139,7 +149,6 @@ namespace Borepin.PageModel
|
||||
{ "instance", _User },
|
||||
};
|
||||
|
||||
_IsDialog = true;
|
||||
_DialogService.ShowDialog("ConfirmDialog", parameters, DeleteCommandExecute_Dialog);
|
||||
}
|
||||
|
||||
@ -175,6 +184,18 @@ namespace Borepin.PageModel
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private ICommand _UpdatePasswordCommand;
|
||||
public ICommand UpdatePasswordCommand
|
||||
{
|
||||
get => _UpdatePasswordCommand;
|
||||
set => SetProperty(ref _UpdatePasswordCommand, value);
|
||||
}
|
||||
|
||||
public void UpdatePasswordCommandExecute()
|
||||
{
|
||||
_User.Manage.Pwd(null, NewPassword);
|
||||
}
|
||||
#endregion
|
||||
}
|
||||
}
|
||||
|
@ -492,6 +492,42 @@ namespace Borepin.Resources.Text {
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Looks up a localized string similar to Change Password.
|
||||
/// </summary>
|
||||
internal static string ProfilePage_ChangePassword {
|
||||
get {
|
||||
return ResourceManager.GetString("ProfilePage_ChangePassword", resourceCulture);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Looks up a localized string similar to New Password:.
|
||||
/// </summary>
|
||||
internal static string ProfilePage_NewPassword {
|
||||
get {
|
||||
return ResourceManager.GetString("ProfilePage_NewPassword", resourceCulture);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Looks up a localized string similar to Old Password:.
|
||||
/// </summary>
|
||||
internal static string ProfilePage_OldPassword {
|
||||
get {
|
||||
return ResourceManager.GetString("ProfilePage_OldPassword", resourceCulture);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Looks up a localized string similar to Update Password.
|
||||
/// </summary>
|
||||
internal static string ProfilePage_UpdatePassword {
|
||||
get {
|
||||
return ResourceManager.GetString("ProfilePage_UpdatePassword", resourceCulture);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Looks up a localized string similar to Scan QR-Code.
|
||||
/// </summary>
|
||||
@ -735,6 +771,33 @@ namespace Borepin.Resources.Text {
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Looks up a localized string similar to Update Password.
|
||||
/// </summary>
|
||||
internal static string UserPage_ChangePassword {
|
||||
get {
|
||||
return ResourceManager.GetString("UserPage_ChangePassword", resourceCulture);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Looks up a localized string similar to New Password.
|
||||
/// </summary>
|
||||
internal static string UserPage_NewPassword {
|
||||
get {
|
||||
return ResourceManager.GetString("UserPage_NewPassword", resourceCulture);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Looks up a localized string similar to Force Password Update.
|
||||
/// </summary>
|
||||
internal static string UserPage_UpdatePassword {
|
||||
get {
|
||||
return ResourceManager.GetString("UserPage_UpdatePassword", resourceCulture);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Looks up a localized string similar to Version.
|
||||
/// </summary>
|
||||
|
@ -263,6 +263,18 @@
|
||||
<data name="PLEASECONNECTTOSERVER" xml:space="preserve">
|
||||
<value>Please connect to Server</value>
|
||||
</data>
|
||||
<data name="ProfilePage_ChangePassword" xml:space="preserve">
|
||||
<value>Change Password</value>
|
||||
</data>
|
||||
<data name="ProfilePage_NewPassword" xml:space="preserve">
|
||||
<value>New Password:</value>
|
||||
</data>
|
||||
<data name="ProfilePage_OldPassword" xml:space="preserve">
|
||||
<value>Old Password:</value>
|
||||
</data>
|
||||
<data name="ProfilePage_UpdatePassword" xml:space="preserve">
|
||||
<value>Update Password</value>
|
||||
</data>
|
||||
<data name="SCANQR" xml:space="preserve">
|
||||
<value>Scan QR-Code</value>
|
||||
</data>
|
||||
@ -344,6 +356,15 @@
|
||||
<data name="USERNAME" xml:space="preserve">
|
||||
<value>Username</value>
|
||||
</data>
|
||||
<data name="UserPage_ChangePassword" xml:space="preserve">
|
||||
<value>Update Password</value>
|
||||
</data>
|
||||
<data name="UserPage_NewPassword" xml:space="preserve">
|
||||
<value>New Password</value>
|
||||
</data>
|
||||
<data name="UserPage_UpdatePassword" xml:space="preserve">
|
||||
<value>Force Password Update</value>
|
||||
</data>
|
||||
<data name="VERSION" xml:space="preserve">
|
||||
<value>Version</value>
|
||||
</data>
|
||||
|
Loading…
x
Reference in New Issue
Block a user