Created login and error handling to get auth token. Refreshing not handled.
This commit is contained in:
30
BodyshopUploader/Utils/LoginHelpers.cs
Normal file
30
BodyshopUploader/Utils/LoginHelpers.cs
Normal file
@@ -0,0 +1,30 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Runtime.InteropServices;
|
||||
using System.Security;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace BodyshopUploader.Utils
|
||||
{
|
||||
public static class LoginHelpers
|
||||
{
|
||||
public static void SaveLoginSettings(string Username, SecureString Password)
|
||||
{
|
||||
Properties.Settings.Default.Username = Username;
|
||||
//Todo: Figure out how to save the secure string. Perhaps serialize to JSON?
|
||||
Properties.Settings.Default.Password = Password;
|
||||
Properties.Settings.Default.Save();
|
||||
}
|
||||
|
||||
public static string DecodePassword (SecureString s)
|
||||
{
|
||||
//Manage the secure string for the password.
|
||||
IntPtr stringPointer = Marshal.SecureStringToBSTR(s);
|
||||
string UP = Marshal.PtrToStringBSTR(stringPointer);
|
||||
Marshal.ZeroFreeBSTR(stringPointer);
|
||||
return UP;
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user