private async Task LoginUser() { TokenModel model = await DataService.GetToken(Codigo, Contraseña); if (!string.IsNullOrEmpty(model.ErrorMessage)) { if (model.ErrorMessage.ToLowerInvariant().Contains("task")) { model.ErrorMessage = "Tiempo de espera excedido. Verifique su conexión a internet e intente nuevamente."; } ErrorLogin = model.ErrorMessage; return; } string _urlUsuario = string.Format("https://www.bcmweb.net/api/Usuario/GetByCredentials/{0}/{1}", Codigo, Contraseña); UsuarioModel usuarioModel = await DataService.GetdataUsuario(_urlUsuario, model.access_token); SharedModel.UserToken = model.access_token; LoginModelEventArgs args = new LoginModelEventArgs { Token = model.access_token, Usuario = usuarioModel, }; UserLogged?.Invoke(this, args); }
public void signOutUser() { FirebaseAuth auth = UserLogged.getFirebaseAuth(); auth.SignOut(); SceneManager.LoadScene(SceneManager.GetActiveScene().buildIndex - 3); }
// goto company page private async void OnCompanyClicked(object sender, EventArgs e) { await UserLogged.ReloadProfile(); var appShell = (AppShell)Shell.Current; appShell.AddMenu_QuanLyCongTy(); if (string.IsNullOrEmpty(UserLogged.CompanyId)) { string action = await DisplayActionSheet(Language.cong_ty, Language.huy, null, Language.dang_ky_cong_ty, Language.dang_ky_nhan_vien); if (action == Language.dang_ky_cong_ty) { await Navigation.PushAsync(new AddCompanyPage()); } else if (action == Language.dang_ky_nhan_vien) { enNumPhone.Text = ""; await ModalRegisterEmployee.Show(); } } else { await Shell.Current.GoToAsync("//" + AppShell.QUANLYCONGTY); } }
private bool TrySave() { try { CopyFields(); _organization.Save(); History.Save(_organization, UserLogged.Get()); ShowHistory(); return(true); } catch (NullReferenceException ex) { MessageBox.Show(ex.Message, "Обязательное поле", MessageBoxButtons.OK, MessageBoxIcon.Error); } catch (NotImplementedException ex) { MessageBox.Show(ex.Message, "Ошибка создания", MessageBoxButtons.OK, MessageBoxIcon.Error); } return(false); }
public IActionResult LoginControl() { var InputUser = SecurityConversor.Md5Calculator(Request.Form["User"]); var InputPassword = SecurityConversor.Md5Calculator(Request.Form["Password"]); var securityContextList = securityContext.Security.ToList(); if (securityContextList.Exists(x => x.User_Name == InputUser && x.Password == InputPassword)) { //instancia singleton de login userLogged = UserLogged.GetInstance(InputUser); //inserción de datos de loging en la tabla correspondiente logginTime.NewUserLogin(GetUserIdLogged()); if (!IsUserLogged()) { return(RedirectToAction("Login", "Security")); } return(RedirectToAction("Index", "Home")); } else { TempData["ErrorLogin"] = "******"; return(RedirectToAction("Login", "Security")); } }
private bool TrySave() { try { if (!IsHaveChanges()) { return(true); } if (!CopyFields()) { return(false); } _organization.Save(); History.Save(_organization, UserLogged.Get()); ShowHistory(); return(true); } catch (NullReferenceException ex) { MessageBox.Show(ex.Message, "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error); return(false); } }
public static UserLogged GetInstance() { if (instance == null) { instance = new UserLogged(); } return(instance); }
public void Battle(BattleType battleType) { StopAnimation(); blockMove = true; Debug.Log("BATTLE!"); UserLogged.GetInstance().battlesFought++; StartCoroutine(LoadScene.LoadBattleScene(battleType)); }
private void LoadFirstTable() { dgvLpuRR.DataSource = _lpuRRList.ToDataTable(UserLogged.Get()); dgvLpuRR.Columns[0].Width = 70; dgvLpuRR.Columns[1].Width = 200; dgvLpuRR.Columns[2].Width = 370; dgvLpuRR.Columns[3].Width = 100; }
public void clickOnUpdateAvatar() { String nickname = this.nickname.text; FirebaseUser currentUser = UserLogged.getLoggedUser(); if (!string.IsNullOrEmpty(nickname)) { if (currentUser != null) { Firebase.Auth.UserProfile profile = new Firebase.Auth.UserProfile { DisplayName = nickname, }; currentUser.UpdateUserProfileAsync(profile).ContinueWith(task => { if (task.IsCanceled) { Debug.LogError("UpdateUserProfileAsync was canceled."); return; } if (task.IsFaulted) { infoMessage.faceColor = new Color32(255, 0, 0, 255); AggregateException ex = task.Exception as AggregateException; if (ex != null) { Firebase.FirebaseException fbEx = null; foreach (Exception e in ex.InnerExceptions) { fbEx = e as Firebase.FirebaseException; if (fbEx != null) { break; } } if (fbEx != null) { infoMessage.text = fbEx.Message; } } return; } infoMessage.faceColor = new Color32(0, 255, 0, 255); infoMessage.text = "User profile updated successfuly!"; GameObject gameObj = GameObject.Find("User"); DontDestroyOnLoad(gameObj); SceneManager.LoadScene(SceneManager.GetActiveScene().buildIndex + 1); }); } } else { infoMessage.faceColor = new Color32(255, 0, 0, 255); infoMessage.text = "Please enter a nickname!"; } }
private static async void OnAuthLinkedCompleted(object sender, AuthenticatorCompletedEventArgs e) { var authenticator = sender as OAuth2Authenticator; if (authenticator != null) { authenticator.Completed -= OnAuthLinkedCompleted; authenticator.Error -= OnAuthLinkedError; } //LoginUser = null; if (e.IsAuthenticated) { // If the user is authenticated, request their basic user data from Google // UserInfoUrl = https://www.googleapis.com/oauth2/v2/userinfo var request = new OAuth2Request("GET", new Uri(UserInfoUrl), null, e.Account); var response = await request.GetResponseAsync(); if (response != null) { // Deserialize the data and store it in the account store // The users email address will be used to identify data in SimpleDB string userJson = await response.GetResponseTextAsync(); GoogleUser googleUser = JsonConvert.DeserializeObject <GoogleUser>(userJson); var ggUser = new User() { FullName = googleUser.Name, Email = googleUser.Email, GoogleId = googleUser.Id, AvatarUrl = googleUser.Picture }; try { ApiResponse apiResponse = await ApiHelper.Put("api/auth/sociallinked", ggUser, true); if (apiResponse.IsSuccess) { var user = JsonConvert.DeserializeObject <User>(apiResponse.Content.ToString()); UserLogged.SaveProfile(user); await Application.Current.MainPage.DisplayAlert("", Language.lien_ket_google_thanh_cong, Language.dong); //MessagingCenter.Send<GoogleHelper, bool>(this, "UpdateSocialLinked", true); } else { throw new Exception(apiResponse.Message); } } catch (Exception ex) { await Application.Current.MainPage.DisplayAlert("", Language.loi_he_thong_vui_long_thu_lai, Language.dong); } } } }
public void CreateUserLogged(ApplicationUser user) { UserLogged userLog = new UserLogged(); ApplicationUser currentUser = this.Context.Users.Find(user.Id); userLog.User = currentUser; this.Context.UserLoggeds.Add(userLog); this.Context.SaveChanges(); }
protected virtual void OnUserLogged(User user) { if (UserLogged != null) { UserLogged.Invoke(this, new LoginEventArgs() { User = user }); } }
private void LoadDictionaries() { if (UserLogged.Get().RoleSF == RolesSF.Пользователь) { ClassForForm.LoadDictionary(cbRealRegion, _realRegionList.ToDataTable(UserLogged.Get())); } else { ClassForForm.LoadDictionary(cbRealRegion, _realRegionList.ToDataTable()); } }
public bool DeletePerson() { if (MessageBox.Show("Вы действительно хотите удалить персону?", "Удаление", MessageBoxButtons.YesNo, MessageBoxIcon.Warning) == System.Windows.Forms.DialogResult.Yes) { Person person = GetPerson(); person.Delete(); History.Save(person, UserLogged.Get(), HistoryAction.Удалил); return(true); } return(false); }
public bool DeleteOrganization() { Organization organization = GetOrganization(); if ((organization != null) && (ClassForForm.DeleteOrganization(organization))) { History.Save(organization, UserLogged.Get(), HistoryAction.Удалил); return(true); } return(false); }
protected void DecodeToken(HttpContext context) { var token = new JwtSecurityTokenHandler() .ReadJwtToken(context.Request.Headers["Authorization"] .ToString() .Replace("Bearer ", string.Empty)) as JwtSecurityToken; userLogged = new UserLogged { Id = Convert.ToInt32(token.Claims.First(claim => claim.Type == "nameid").Value), Nome = token.Subject }; }
public ViewResult AuthenticatorSMS(UserLogged userLogged) { if (ModelState.IsValid) { if (userLogged.SMSCodeVerify.Equals(userLogged.SMSCode)) { ViewBag.Message = "Se verificó correctamente el SMS enviado. " + userLogged.SMSCode; return(View(userLogged)); } } ViewBag.Message = "SMS ingresado es incorrecto. "; return(View(userLogged)); }
public PersonListController(DataGridView dgv, Organization organization) : base(dgv) { _organization = organization; _dgv = dgv; _seacher = new SearchInDgv(_dgv); _personList = PersonList.GetUniqueInstance(); _user = UserLogged.Get(); _filtredDGV = new FilteredDGV(dgv); _sortDGV = new SortDGV(dgv); }
public static HabitResponse AddLog(Guid userID, Guid id) { var data = HabitLogs.AddLog(userID, id); if (data == null) { return(null); } UserLogged.Notify(data); return(data); }
private void GetSettings() { Settings settings = new Settings(); if (UserLogged.Get().RoleSF == RolesSF.Администратор) { SetEditMode(true); } else { SetEditMode(settings.GetEditMode()); } }
public ActionResult <UserLogged> Post(UserLogin userLogin) { var id = _userService.Authenticate(userLogin.Username, userLogin.Password); if (string.IsNullOrEmpty(id)) { return(Unauthorized()); } var token = _userService.GenerateJwtToken(id, _appSettings.Secret); var userLogged = new UserLogged(id, userLogin.Username, token); return(Ok(userLogged)); }
// update avatar to sql server and mongodb. async void UpdateAvatar(Plugin.Media.Abstractions.MediaFile file, string fileName) { if (file == null) { return; } viewModel.IsLoading = true; StreamContent content = new StreamContent(file.GetStream()); content.Headers.ContentDisposition = new ContentDispositionHeaderValue("form-data") { Name = "files", FileName = fileName }; MultipartFormDataContent form = new MultipartFormDataContent(); form.Add(content); var apiResponse = await BsdHttpClient.Instance().PostAsync(ApiRouter.USER_AVATAR_UPLOAD, form); if (apiResponse.IsSuccessStatusCode) { string AvatarUrl = "avatar/" + fileName; ApiResponse response = await ApiHelper.Post(ApiRouter.USER_AVATAR_UPDATE, AvatarUrl, true, false); if (response.IsSuccess) { viewModel.User.AvatarUrl = AvatarUrl; string AvatarFullUrl = viewModel.User.AvatarFullUrl; image.Source = AvatarFullUrl; UserLogged.SaveAvatar(AvatarFullUrl); MessagingCenter.Send <ProfilePage, string>(this, "UpdateAvatar", AvatarUrl); await DisplayAlert("", Language.cap_nhat_anh_dai_dien_thanh_cong, Language.dong); } else { await DisplayAlert("", Language.khong_cap_nhat_duoc_anh_dai_dien, Language.dong); } } else { await DisplayAlert("", Language.khong_cap_nhat_duoc_anh_dai_dien, Language.dong); } viewModel.IsLoading = false; }
private void btnOK_Click(object sender, EventArgs e) { CopyFields(); string res = _userLPU.Save(UserLogged.Get()); if (res == "1") { DialogResult = System.Windows.Forms.DialogResult.OK; } else { MessageBox.Show("Перемещение не возможно, так как " + res, "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error); } }
public async void Init() { if (UserLogged.IsLogged) { await UserLogged.ReloadProfile(); AccountShellContent.Content = new AccountPage(); SetLogoutMenuItem(); } else { AccountShellContent.Content = new LoginPage(); } AddMenu_QuanLyCongTy(); AddMenu_QuanLyMoiGioi(); }
public async Task CreateSession(WorkShop.Domain.Client.DTO.UserLogged userLoggedDTO) { var userLogged = new UserLogged(userLoggedDTO.UserId, userLoggedDTO.DataLogged, userLoggedDTO.Ip); _IUserLoggedRepository.Add(userLogged); await _IUserLoggedRepository.SaveChangesAsync(); userLoggedDTO.DataCheck = userLogged.DataCheck; userLoggedDTO.DataLogged = userLogged.DataLogged; userLoggedDTO.Hash = userLogged.Hash; userLoggedDTO.Ip = userLogged.Ip; userLoggedDTO.UserId = userLogged.UserId; }
private async void click_login(object sender, EventArgs e) { try { /**/ if (string.IsNullOrEmpty(entryUsername.Text)) { await Shell.Current.DisplayAlert("", "Nhập email hoặc số điện thoại", "Đóng"); return; } if (string.IsNullOrEmpty(entryPassword.Text)) { await Shell.Current.DisplayAlert("", "Nhập mật khẩu", "Đóng"); return; } string userName = entryUsername.Text.Trim(); string passWord = entryPassword.Text.Trim(); ApiResponse loginResponse = await ApiHelper.Login(userName, passWord); if (loginResponse.IsSuccess) { AuthResponse authResponse = JsonConvert.DeserializeObject <AuthResponse>(loginResponse.Content.ToString()); UserLogged.UserName = userName; UserLogged.Password = passWord; UserLogged.SaveLogin(authResponse); Application.Current.MainPage = new AppShell(); } else { string messageError = loginResponse.GetFirstErrorMessage(); if (string.IsNullOrEmpty(messageError)) { messageError = "Lỗi đăng nhập, vui lòng thử lại sau."; } await Shell.Current.DisplayAlert("", messageError, "Đóng"); } } catch (Exception ex) { Console.WriteLine(ex); } }
// moi gioi private async void OpenModalDangKyMoiGioi_Tapped(object sender, EventArgs e) { await UserLogged.ReloadProfile(); var appShell = (AppShell)Shell.Current; appShell.AddMenu_QuanLyMoiGioi(); if (UserLogged.Type == 1) { await Shell.Current.GoToAsync("//" + AppShell.QUANLYMOIGIOI); } else { await DangKyMoiGioi(); } }
public void AddComment(AddCommentBindingModel model) { Snippet snippet = this.Context.Snippets.FirstOrDefault(s => s.Id == model.SnippetId); DateTime currentTime = DateTime.Now; UserLogged author = this.Context.UserLoggeds.FirstOrDefault(u => u.User.Id == model.UserId); string content = model.Content; Comment comment = new Comment() { Author = author, Content = content, CreationTime = currentTime, Snippet = snippet }; this.Context.Comments.Add(comment); this.Context.SaveChanges(); }
public async void Logout_Clicked(object sender, EventArgs e) { var result = await DisplayAlert(Language.thong_bao, Language.ban_co_chac_chan_muon_dang_xuat, Language.dong_y, Language.huy); if (!result) { return; } string language = LanguageSettings.Language; await ApiHelper.Post(ApiRouter.USER_LOGGOUT, null, true); UserLogged.Logout(); App.SetCultureInfo(language); Application.Current.MainPage = new AppShell(); }