Added automatic login using auth tokens IO-403
This commit is contained in:
@@ -6,6 +6,7 @@ using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using System.Windows;
|
||||
|
||||
|
||||
namespace BodyshopPartner.ViewModels
|
||||
{
|
||||
public partial class LoginViewModel : BaseViewModel
|
||||
@@ -15,6 +16,34 @@ namespace BodyshopPartner.ViewModels
|
||||
public LoginViewModel()
|
||||
{
|
||||
logger.Trace("Login VM Created.");
|
||||
|
||||
AutoLogin();
|
||||
|
||||
|
||||
}
|
||||
|
||||
private async Task AutoLogin()
|
||||
{
|
||||
Loading = true;
|
||||
string AuthToken = Properties.Settings.Default.AuthToken;
|
||||
string RefreshToken = Properties.Settings.Default.RefreshToken;
|
||||
|
||||
|
||||
if (!String.IsNullOrEmpty(AuthToken) && !String.IsNullOrEmpty(RefreshToken))
|
||||
{
|
||||
//Attempt auto login.
|
||||
logger.Debug("Good to attempt auto login.");
|
||||
(Error, ErrorMsg) = await Utils.Auth.AutoLogin(AuthToken, RefreshToken);
|
||||
if (ErrorMsg == null)
|
||||
{
|
||||
App.Current.MainWindow.Hide();
|
||||
Views.Main m = new Views.Main();
|
||||
m.Show();
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
Loading = false;
|
||||
}
|
||||
|
||||
private async Task LoginAsync(Window W)
|
||||
@@ -25,7 +54,7 @@ namespace BodyshopPartner.ViewModels
|
||||
|
||||
logger.Trace("Attempting to login as user: {0}", UserName);
|
||||
(Error, ErrorMsg) = await Utils.Auth.LoginAsync(UserName, Utils.LoginHelpers.DecodePassword(UserPassword));
|
||||
if(ErrorMsg ==null)
|
||||
if (ErrorMsg == null)
|
||||
{
|
||||
Views.Main m = new Views.Main();
|
||||
m.Show();
|
||||
|
||||
@@ -148,6 +148,7 @@ namespace BodyshopPartner.ViewModels
|
||||
async p =>
|
||||
{
|
||||
await InstallUpdates();
|
||||
UpdateAvailable = false;
|
||||
});
|
||||
}
|
||||
return _installUpdatesCommand;
|
||||
|
||||
Reference in New Issue
Block a user