Added creation of owner object. Vehicle addition now dynamic based on presence of VIN.
This commit is contained in:
@@ -14,9 +14,13 @@ namespace BodyshopUploader.Utils
|
||||
public static FirebaseAuthLink authlink;
|
||||
static FirebaseAuthProvider ap = new FirebaseAuthProvider(new FirebaseConfig(Utils.AppMetaData.FirebaseAPIKey_DEV)); //TODO: Update this to be a dynamic key. Perhaps a function that fetches?
|
||||
private static Timer tokenTimer = new Timer();
|
||||
private static string U;
|
||||
private static string P;
|
||||
|
||||
public async static Task<(bool, string)> LoginAsync(string Username, string Password)
|
||||
{
|
||||
U = Username;
|
||||
P = Password;
|
||||
try
|
||||
{
|
||||
authlink = await ap.SignInWithEmailAndPasswordAsync(Username, Password);
|
||||
@@ -26,7 +30,6 @@ namespace BodyshopUploader.Utils
|
||||
logger.Trace("Firebase Refresh Token {0}.", authlink.RefreshToken);
|
||||
logger.Trace("Firebase Auth Token expires in {0} seconds.", authlink.ExpiresIn);
|
||||
tokenTimer.Interval = (authlink.ExpiresIn - 600) * 1000; //Set the token to refresh 10 minutes before it has to.
|
||||
//tokenTimer.Interval = 10000; //Set the token to refresh 10 minutes before it has to.
|
||||
logger.Trace("Refresh timer interval set to {0}ms", (authlink.ExpiresIn - 600) * 1000);
|
||||
tokenTimer.Elapsed += TokenTimer_Tick;
|
||||
tokenTimer.Start();
|
||||
@@ -73,17 +76,21 @@ namespace BodyshopUploader.Utils
|
||||
logger.Debug("New token: {0}", e.FirebaseAuth.FirebaseToken);
|
||||
}
|
||||
|
||||
private static void TokenTimer_Tick(object sender, ElapsedEventArgs e)
|
||||
private static async Task RefreshToken()
|
||||
{
|
||||
//Gotta do some stuff now that i got a new token!
|
||||
//Maybe the token auto refreshes?
|
||||
logger.Info("Timer Old Token {0}", authlink.FirebaseToken);
|
||||
//await authlink.RefreshUserDetails();
|
||||
//logger.Info("new Token {0}", authlink.FirebaseToken);
|
||||
//tokenTimer.Stop();
|
||||
//tokenTimer.Interval = (authlink.ExpiresIn - 600) * 1000; //Set the token to refresh 10 minutes before it has to.
|
||||
//tokenTimer.Interval = 10000;
|
||||
//tokenTimer.Start();
|
||||
authlink = await ap.SignInWithEmailAndPasswordAsync(U, P);
|
||||
logger.Info("new Token {0}", authlink.FirebaseToken);
|
||||
tokenTimer.Stop();
|
||||
tokenTimer.Interval = (authlink.ExpiresIn - 600) * 1000; //Set the token to refresh 10 minutes before it has to.
|
||||
tokenTimer.Start();
|
||||
}
|
||||
|
||||
private static async void TokenTimer_Tick(object sender, ElapsedEventArgs e)
|
||||
{
|
||||
await RefreshToken();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user