public void CheckAutoLogin(NodeAddedEvent e, SecuredClientSessionNode clientSession, SingleNode <ScreensRegistryComponent> screenRegistry, SingleNode <EntranceValidationRulesComponent> validationRules) { string str = PlayerPrefs.GetString("TOLogin"); string str2 = PlayerPrefs.GetString("TOToken"); if (!clientSession.Entity.HasComponent <InviteComponent>() && (!string.IsNullOrEmpty(str2) && !string.IsNullOrEmpty(str))) { AutoLoginUserEvent eventInstance = new AutoLoginUserEvent { Uid = str, EncryptedToken = PasswordSecurityUtils.RSAEncrypt(clientSession.sessionSecurityPublic.PublicKey, Convert.FromBase64String(str2)), HardwareFingerprint = HardwareFingerprintUtils.HardwareFingerprint }; base.ScheduleEvent(eventInstance, clientSession); } else if (this.IsSteamUserLogin()) { base.ScheduleEvent <ShowFirstScreenEvent <EntranceScreenComponent> >(screenRegistry); base.ScheduleEvent <RequestSteamAuthenticationEvent>(clientSession); } else if (string.IsNullOrEmpty(SaveLoginSystem.GetSavedLogin()) && string.IsNullOrEmpty(clientSession.webId.WebIdUid)) { base.ScheduleEvent <ShowFirstScreenEvent <RegistrationScreenComponent> >(screenRegistry); } else { base.ScheduleEvent <ShowFirstScreenEvent <EntranceScreenComponent> >(screenRegistry); } }
public void QuickRegistrationNewUser(ButtonClickEvent e, SingleNode <QuickRegistrationButtonComponent> node, [JoinByScreen] SingleNode <RegistrationScreenComponent> screen, [JoinAll] SecuredClientSessionNode clientSession, [JoinAll] Optional <SingleNode <SteamMarkerComponent> > steam, [JoinAll] Optional <SubscribeCheckboxNode> subscribeCheckbox) { byte[] digest = PasswordSecurityUtils.GetDigest(Path.GetRandomFileName()); RequestRegisterUserEvent eventInstance = new RequestRegisterUserEvent { Uid = string.Empty, Email = string.Empty, HardwareFingerprint = HardwareFingerprintUtils.HardwareFingerprint, EncryptedPasswordDigest = PasswordSecurityUtils.RSAEncryptAsString(clientSession.sessionSecurityPublic.PublicKey, digest), Steam = steam.IsPresent(), Subscribed = !subscribeCheckbox.IsPresent() || subscribeCheckbox.Get().checkbox.IsChecked, QuickRegistration = true }; base.ScheduleEvent(eventInstance, clientSession); clientSession.Entity.AddComponent(new AutoLoginTokenAwaitingComponent(digest)); screen.component.LockScreen(true); }
public void SendPasswordToServer(PersonalPasscodeEvent e, ClientSessionRegularNode clientSession, [JoinAll] SingleNode <EntranceScreenComponent> entranceScreen) { if (e.Passcode.Length == 0) { base.Log.Error("Invalid passcode for user: " + entranceScreen.component.Login); } else { string password = entranceScreen.component.Password; bool rememberMe = entranceScreen.component.RememberMe; LoginByPasswordEvent eventInstance = new LoginByPasswordEvent { RememberMe = rememberMe, PasswordEncipher = PasswordSecurityUtils.SaltPassword(e.Passcode, password), HardwareFingerprint = HardwareFingerprintUtils.HardwareFingerprint }; base.ScheduleEvent(eventInstance, clientSession); if (rememberMe) { this.AddAwaitingTokenComponent(password, clientSession.Entity); } } }
public void RegisterNewUser(ButtonClickEvent e, SingleNode <FinishRegistrationButtonComponent> node, [JoinByScreen] SingleNode <RegistrationScreenComponent> screen, [JoinAll] SecuredClientSessionNode clientSession, [JoinByUser] Optional <SingleNode <UserIncompleteRegistrationComponent> > user, [JoinAll] Optional <SingleNode <SteamMarkerComponent> > steam, [JoinAll] Optional <SubscribeCheckboxNode> subscribeCheckbox) { RegistrationScreenComponent component = screen.component; byte[] digest = PasswordSecurityUtils.GetDigest(component.Password); RequestRegisterUserEvent eventInstance = new RequestRegisterUserEvent { Uid = component.Uid, HardwareFingerprint = HardwareFingerprintUtils.HardwareFingerprint, EncryptedPasswordDigest = PasswordSecurityUtils.RSAEncryptAsString(clientSession.sessionSecurityPublic.PublicKey, digest), Email = component.Email, Steam = steam.IsPresent(), Subscribed = !subscribeCheckbox.IsPresent() || subscribeCheckbox.Get().checkbox.IsChecked }; EventBuilder builder = base.NewEvent(eventInstance).Attach(clientSession); if (user.IsPresent()) { builder.Attach(user.Get()); } builder.Schedule(); clientSession.Entity.AddComponent(new AutoLoginTokenAwaitingComponent(digest)); screen.component.LockScreen(true); }
private void AddAwaitingTokenComponent(string password, Entity clientSession) { clientSession.AddComponent(new AutoLoginTokenAwaitingComponent(PasswordSecurityUtils.GetDigest(password))); }