Arma Reforger Explorer 1.7.0.54
Arma Reforger Code Explorer by Zeroy - Thanks to MisterOutofTime
Loading...
Searching...
No Matches
LoginDialogUI.c
Go to the documentation of this file.
1//------------------------------------------------------------------------------------------------
3{
4 protected const string USERNAME_WIDGET = "UserName";
5 protected const string PASSWORD_WIDGET = "Password";
6
9
10 //------------------------------------------------------------------------------------------------
12 {
13 super.OnMenuOpen(preset);
14
15 // Load credentials
16 string name = BohemiaAccountApi.GetEmail();
18 if (m_UserName)
19 {
20 m_UserName.SetValue(name);
21 m_UserName.m_OnChanged.Insert(CheckFilledEditBoxes);
22
23 GetGame().GetWorkspace().SetFocusedWidget(m_UserName.GetRootWidget());
24 }
25
27 if (m_Password)
28 m_Password.m_OnChanged.Insert(CheckFilledEditBoxes);
29
31 }
32
33 //------------------------------------------------------------------------------------------------
34 override void OnConfirm()
35 {
37 return;
38
39 string user = m_UserName.GetValue().Trim();
40
41 if (!VerifyFormatting(user))
42 {
44 return;
45 }
46
47 // Verify credentials
48 BohemiaAccountApi.Link(m_Callback, user, m_Password.GetValue(), "");
49
50 super.OnConfirm();
51 }
52
53 //------------------------------------------------------------------------------------------------
54 override void OnFailDelayed(BackendCallback callback)
55 {
56 if (callback.GetHttpCode() == SCR_ELoginFailReason.TWO_FACTOR_AUTHENTICATION)
57 {
59 Close();
60 }
61 else
62 {
63 super.OnFailDelayed(callback);
64 }
65 }
66
67 //------------------------------------------------------------------------------------------------
68 override void ShowWarningMessage(bool show)
69 {
70 super.ShowWarningMessage(show);
71
72 if (!show)
73 return;
74
75 if (m_UserName)
76 m_UserName.OnInvalidInput();
77
78 if (m_Password)
79 m_Password.OnInvalidInput();
80 }
81
82 //------------------------------------------------------------------------------------------------
83 // Username must be [email protected] format
84 override bool VerifyFormatting(string text)
85 {
86 // check for spaces and @
87 if (text.IsEmpty() || text.Contains(" ") || !text.Contains("@") || text.LastIndexOf("@") == text.Length() - 1)
88 return false;
89
90 array<string> substrings = {};
91 text.Split("@", substrings, true);
92
93 // make sure there's only one @
94 if (substrings.IsEmpty() || substrings.Count() != 2)
95 return false;
96
97 // check if the domain contains . and it's not the last symbol
98 string domain = substrings[1];
99 if (domain.IsEmpty() || !domain.Contains(".") || domain[0] == "." || domain.LastIndexOf(".") == domain.Length() - 1)
100 return false;
101
102 // make sure there's no symbols except . in the domain string
103 for (int i = 0; i < domain.Length(); i++)
104 {
105 string char = domain[i];
106
107 if (char == ".")
108 continue;
109
110 int ascii = char.ToAscii();
111
112 bool number = ascii >= 48 && ascii <= 57;
113 bool capLetter = ascii >= 65 && ascii <= 90;
114 bool letter = ascii >= 97 && ascii <= 122;
115
116 if (!number && !capLetter && !letter)
117 return false;
118 }
119
120 return super.VerifyFormatting(text);
121 }
122
123 //------------------------------------------------------------------------------------------------
124 protected void CheckFilledEditBoxes()
125 {
126 m_bForceConfirmButtonDisabled = m_UserName.GetValue().IsEmpty() || m_Password.GetValue().IsEmpty();
127 if (m_ConfirmButton)
129 }
130}
131
132//------------------------------------------------------------------------------------------------
133class SCR_LoginDialogConsoleUI : SCR_LoginDialogUI
134{
135 protected const string OVERLAY_MAIN = "OverlayMain";
136
138
139 //------------------------------------------------------------------------------------------------
141 {
142 super.OnMenuOpen(preset);
143
144 m_wOverlayMain = OverlayWidget.Cast(m_wRoot.FindAnyWidget(OVERLAY_MAIN));
145 }
146
147 //------------------------------------------------------------------------------------------------
148 // The dialog has a unique structure so we need to attach the loading overlay to a different Widget than other dialogs
150 {
151 return m_wOverlayMain;
152 }
153}
ArmaReforgerScripted GetGame()
Definition game.c:1398
SCR_LoginDialogUI OVERLAY_MAIN
override OverlayWidget GetDialogBaseOverlay()
OverlayWidget m_wOverlayMain
Widget m_wRoot
override void OnMenuOpen()
static SCR_EditBoxComponent GetEditBoxComponent(string name, Widget parent, bool searchAllChildren=true)
const string PASSWORD_WIDGET
SCR_EditBoxComponent m_Password
override bool VerifyFormatting(string text)
override void OnFailDelayed(BackendCallback callback)
override void OnMenuOpen(SCR_ConfigurableDialogUiPreset preset)
override void OnConfirm()
override void ShowWarningMessage(bool show)
SCR_EditBoxComponent m_UserName
const string USERNAME_WIDGET
SCR_InputButtonComponent m_ConfirmButton
static void Create2FADialog(string name, string code)