mirror of
https://dev.azure.com/TeilRad/sharee.bike%20App/_git/Code
synced 2025-04-19 11:37:28 +02:00
Code updated to 3.0.238
This commit is contained in:
parent
3302d80678
commit
9c6a1fa92b
257 changed files with 7763 additions and 2861 deletions
|
@ -17,6 +17,7 @@ namespace TINK.Model.User.Account
|
|||
PickLoggingLevel = 64, // Allows to select the logging level.
|
||||
ShowDiagnostics = 128, // Turns on display of diagnostics.
|
||||
SwitchNoSiteCaching = 1024, // Allows to turn off/ on caching of sites displayed in app hosted by COPRI
|
||||
ReportLevel = 2048, // Allows extent to show error messages.
|
||||
All = PickCopriServer +
|
||||
ManageCopriCacheExpiration +
|
||||
ManagePolling +
|
||||
|
@ -24,7 +25,8 @@ namespace TINK.Model.User.Account
|
|||
PickLocationServiceImplementation +
|
||||
PickLoggingLevel +
|
||||
ShowDiagnostics +
|
||||
SwitchNoSiteCaching,
|
||||
SwitchNoSiteCaching +
|
||||
ReportLevel,
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
|
@ -48,24 +50,24 @@ namespace TINK.Model.User.Account
|
|||
public class Account : IAccount
|
||||
{
|
||||
/// <summary> Constructs an account object.</summary>
|
||||
/// <param name="p_oMail">Mail addresss.</param>
|
||||
/// <param name="p_Pwd">Password.</param>
|
||||
/// <param name="p_oSessionCookie">Session cookie from copri.</param>
|
||||
/// <param name="p_strGroup">Group holdig info about Group (TINK, Konrad, ...)</param>
|
||||
/// <param name="mail">Mail addresss.</param>
|
||||
/// <param name="password">Password.</param>
|
||||
/// <param name="sessionCookie">Session cookie from copri.</param>
|
||||
/// <param name="group">Group holdig info about Group (TINK, Konrad, ...)</param>
|
||||
/// <param name="p_iDebugLevel">Flag which controls display of debug settings.</param>
|
||||
public Account(
|
||||
string p_oMail,
|
||||
string p_Pwd,
|
||||
string p_oSessionCookie,
|
||||
IEnumerable<string> p_strGroup,
|
||||
string mail,
|
||||
string password,
|
||||
string sessionCookie,
|
||||
IEnumerable<string> group,
|
||||
Permissions debugLevel = Permissions.None)
|
||||
{
|
||||
Mail = p_oMail;
|
||||
Pwd = p_Pwd;
|
||||
SessionCookie = p_oSessionCookie;
|
||||
Mail = mail;
|
||||
Pwd = password;
|
||||
SessionCookie = sessionCookie;
|
||||
DebugLevel = debugLevel;
|
||||
Group = p_strGroup != null
|
||||
? new HashSet<string>(p_strGroup).ToList()
|
||||
Group = group != null
|
||||
? new HashSet<string>(group).ToList()
|
||||
: throw new ArgumentException("Can not instantiate account object. Reference to group list must not be empty.");
|
||||
}
|
||||
|
||||
|
|
|
@ -1,26 +1,26 @@
|
|||
namespace TINK.Model.User.Account
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace TINK.Model.User.Account
|
||||
{
|
||||
/// <summary>
|
||||
/// Interface to manage an account store.
|
||||
/// </summary>
|
||||
/// <summary>Interface to manage an account store.</summary>
|
||||
public interface IStore
|
||||
{
|
||||
/// <summary>
|
||||
/// Reads mail address and password from account store.
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
IAccount Load();
|
||||
Task<IAccount> Load();
|
||||
|
||||
/// <summary>
|
||||
/// Writes mail address and password to account store.
|
||||
/// </summary>
|
||||
/// <param name="p_oMailAndPwd"></param>
|
||||
void Save(IAccount p_oMailAndPwd);
|
||||
/// <param name="mailAndPwd"></param>
|
||||
Task Save(IAccount mailAndPwd);
|
||||
|
||||
/// <summary>
|
||||
/// Deletes mail address and password from account store.
|
||||
/// </summary>
|
||||
/// <returns> Empty account instance if deleting succeeded.</returns>
|
||||
IAccount Delete(IAccount p_oMailAndPwd);
|
||||
IAccount Delete(IAccount mailAndPwd);
|
||||
}
|
||||
}
|
||||
|
|
67
TINKLib/Model/User/Account/Store.cs
Normal file
67
TINKLib/Model/User/Account/Store.cs
Normal file
|
@ -0,0 +1,67 @@
|
|||
using Serilog;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Threading.Tasks;
|
||||
using Xamarin.Essentials;
|
||||
|
||||
namespace TINK.Model.User.Account
|
||||
{
|
||||
public class Store : IStore
|
||||
{
|
||||
/// <summary> Holds id of the debug level key. </summary>
|
||||
private const string KEY_DEBUGLEVEL = "DebugLevel";
|
||||
|
||||
/// <summary> Holds the id of the session. </summary>
|
||||
private const string KEY_SESSIONCOOKIE = "SessionCookie";
|
||||
|
||||
/// <summary> Holds id of the mail address key. </summary>
|
||||
private const string KEY_MAILADDRESS = "MailAddress";
|
||||
|
||||
public IAccount Delete(IAccount account)
|
||||
{
|
||||
SecureStorage.RemoveAll();
|
||||
return new EmptyAccount();
|
||||
}
|
||||
|
||||
public async Task<IAccount> Load()
|
||||
{
|
||||
|
||||
var mail = string.Empty;
|
||||
var sessionCookie = string.Empty;
|
||||
var debugLevel = Permissions.None;
|
||||
|
||||
try
|
||||
{
|
||||
mail = await SecureStorage.GetAsync(KEY_MAILADDRESS);
|
||||
sessionCookie = await SecureStorage.GetAsync(KEY_SESSIONCOOKIE);
|
||||
Enum.TryParse(await SecureStorage.GetAsync(KEY_DEBUGLEVEL), out debugLevel);
|
||||
|
||||
}
|
||||
catch (Exception exception)
|
||||
{
|
||||
Log.ForContext<Store>().Error("Loading account from store failed. {Exception}", exception);
|
||||
}
|
||||
|
||||
return new Account(
|
||||
mail,
|
||||
string.Empty,
|
||||
sessionCookie,
|
||||
new List<string>(),
|
||||
debugLevel);
|
||||
}
|
||||
|
||||
public async Task Save(IAccount mailAndPwd)
|
||||
{
|
||||
try
|
||||
{
|
||||
await SecureStorage.SetAsync(KEY_MAILADDRESS, mailAndPwd.Mail);
|
||||
await SecureStorage.SetAsync(KEY_SESSIONCOOKIE, mailAndPwd.SessionCookie);
|
||||
await SecureStorage.SetAsync(KEY_DEBUGLEVEL, mailAndPwd.DebugLevel.ToString());
|
||||
}
|
||||
catch (Exception exception)
|
||||
{
|
||||
Log.ForContext<Store>().Error("Saving account from store failed. {Exception}", exception);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue