-
Notifications
You must be signed in to change notification settings - Fork 16
Expand file tree
/
Copy pathReloginScript.cs
More file actions
57 lines (52 loc) · 1.33 KB
/
Copy pathReloginScript.cs
File metadata and controls
57 lines (52 loc) · 1.33 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
using UnityEngine;
using UnityEngine.UI;
using UnityEngine.SceneManagement;
using Cysharp.Threading.Tasks;
using Immutable.Passport;
public class ReloginScript : MonoBehaviour
{
[SerializeField] private Text Output;
/// <summary>
/// Uses the existing credentials to re-login to Passport.
/// </summary>
public void Relogin()
{
ReloginAsync();
}
private async UniTaskVoid ReloginAsync()
{
if (Passport.Instance == null)
{
ShowOutput("Passport Instance is null");
return;
}
ShowOutput("Re-logging into Passport using saved credentials...");
try
{
bool loggedIn = await Passport.Instance.Login(useCachedSession: true);
if (loggedIn)
{
NavigateToAuthenticatedScene();
}
else
{
ShowOutput("Could not re-login using saved credentials");
}
}
catch (System.Exception ex)
{
ShowOutput($"Failed to re-login: {ex.Message}");
}
}
private void NavigateToAuthenticatedScene()
{
SceneManager.LoadScene("AuthenticatedScene");
}
private void ShowOutput(string message)
{
if (Output != null)
{
Output.text = message;
}
}
}