//this method get the details of particular user public Creadential Check(IdPassword cread) { Creadential cre = new Creadential(); User master = _context.Get(cread.Email); if (master == null) { cre.Status = "notexist"; return(cre); } else if (master.Email == cread.Email && master.Password == cread.Password) { _context.SetLoggedIn(master.Id, true); cre.Status = "success"; cre.UserId = master.Id; cre.UserName = master.FirstName; cre.Email = master.Email; return(cre); } else if (master.Email == cread.Email && master.Password != cread.Password) { cre.Status = "exist"; return(cre); } else { cre.Status = "error"; return(cre); } }
public ApiResponse <bool> Login(IdPassword usuario) { ApiResponse <bool> response = new ApiResponse <bool>(); try { IdPasswordModel user = _context.UdelarAdmins.SingleOrDefault(u => u.Id == usuario.Id); if (user != null) { response.Data = BCrypt.Net.BCrypt.Verify(usuario.Password, user.Password); } else { response.Data = false; response.Status = 500; response.Success = false; response.Message = "Usuario no encontrado"; } } catch (Exception e) { response.Status = 500; response.Success = false; response.Message = e.Message; } return(response); }
private JwtSecurityToken GenerarToken(IdPassword login) { string ValidIssuer = _configuration["ApiAuth:Issuer"]; string ValidAudience = _configuration["ApiAuth:Audience"]; SymmetricSecurityKey IssuerSigningKey = new SymmetricSecurityKey(Encoding.UTF8.GetBytes(_configuration["ApiAuth:SecretKey"])); DateTime dtFechaExpiraToken; DateTime now = DateTime.Now; dtFechaExpiraToken = DateTime.UtcNow.AddHours(24); var claims = new[] { new Claim(Constantes.JWT_CLAIM_USUARIO, login.Id), new Claim(ClaimTypes.Role, "admin") }; return(new JwtSecurityToken ( issuer: ValidIssuer, audience: ValidAudience, claims: claims, expires: dtFechaExpiraToken, notBefore: now, signingCredentials: new SigningCredentials(IssuerSigningKey, SecurityAlgorithms.HmacSha256) )); }
public IActionResult Login([FromBody] IdPassword usuario) { ApiResponse <bool> usu = _uadminManager.Login(usuario); ApiResponse <string> response = new ApiResponse <string>(); if (usu.Data) { var token = GenerarToken(usuario); response.Data = new JwtSecurityTokenHandler().WriteToken(token); } else { response.Success = false; response.Status = 204; response.Message = "Usuario y/o password incorrectos"; } return(Ok(response)); }
public ApiResponse <List <IdPassword> > AddKey(IdPassword usuario) { ApiResponse <List <IdPassword> > response = new ApiResponse <List <IdPassword> >(); try { usuario.Password = BCrypt.Net.BCrypt.HashPassword(usuario.Password); IdPasswordModel user = new IdPasswordModel(usuario.Id, usuario.Password); _context.UdelarAdmins.Add(user); _context.SaveChanges(); response.Data = _context.UdelarAdmins.Select(u => _mapper.Map <IdPassword>(u)).ToList(); } catch (Exception e) { response.Status = 500; response.Success = false; response.Message = e.Message; } return(response); }
public void SignUp_Service_Check_Method_To_Get_Details() { //Arrange var idPass = new IdPassword(); idPass.Email = "preetam"; idPass.Password = "******"; User master = new User(); master.Email = "preetam"; master.Password = "******"; master.FirstName = "preetam"; master.Id = 1; var creadential = new Creadential(); creadential.UserId = 1; creadential.Status = "success"; creadential.UserName = "******"; creadential.Email = "preetam"; //mocking RequestRepository var mockRepoReq = new Mock <ISignUpRepository>(); //mocking GetAll() of RequestRepository mockRepoReq.Setup(x => x.Get(creadential.Email)).Returns(master); mockRepoReq.Setup(x => x.SetLoggedIn(1, true)).Returns(true); SignUpService obj = new SignUpService(mockRepoReq.Object); //Act var res = obj.Check(idPass); //Assert Assert.NotNull(res); Assert.Equal(creadential.Email, res.Email); Assert.Equal(creadential.Status, res.Status); Assert.Equal(creadential.UserName, res.UserName); Assert.Equal(creadential.UserId, res.UserId); }
private void ActivateLicenseGUI() { GUILayout.Label(GUI.MakeLabel("Activate license", true), InspectorEditor.Skin.Label); var selectLicenseRect = GUILayoutUtility.GetLastRect(); selectLicenseRect.x += selectLicenseRect.width; selectLicenseRect.width = 28; selectLicenseRect.x -= selectLicenseRect.width; selectLicenseRect.y -= EditorGUIUtility.standardVerticalSpacing; var selectLicensePressed = InspectorGUI.Button(selectLicenseRect, MiscIcon.Locate, UnityEngine.GUI.enabled, "Select license file on this computer", 1.25f); if (selectLicensePressed) { var sourceLicense = EditorUtility.OpenFilePanel("Copy AGX Dynamics license file", ".", $"{AGXUnity.LicenseManager.GetLicenseExtension( AGXUnity.LicenseInfo.LicenseType.Service ).Remove( 0, 1 )}," + $"{AGXUnity.LicenseManager.GetLicenseExtension( AGXUnity.LicenseInfo.LicenseType.Legacy ).Remove( 0, 1 )}"); if (!string.IsNullOrEmpty(sourceLicense)) { var targetLicense = AGXUnity.IO.Environment.FindUniqueFilename($"{LicenseDirectory}/{Path.GetFileName( sourceLicense )}").PrettyPath(); if (EditorUtility.DisplayDialog("Copy AGX Dynamics license", $"Copy \"{sourceLicense}\" to \"{targetLicense}\"?", "Yes", "Cancel")) { try { File.Copy(sourceLicense, targetLicense, false); StartUpdateLicenseInformation(); GUIUtility.ExitGUI(); } catch (ExitGUIException) { throw; } catch (System.Exception e) { Debug.LogException(e); } } } } using (InspectorGUI.IndentScope.Single) { m_licenseActivateData.Id = EditorGUILayout.TextField(GUI.MakeLabel("License Id"), m_licenseActivateData.Id, InspectorEditor.Skin.TextField); if (m_licenseActivateData.Id.Any(c => !char.IsDigit(c))) { m_licenseActivateData.Id = new string( m_licenseActivateData.Id.Where(c => char.IsDigit(c)).ToArray()); } m_licenseActivateData.Password = EditorGUILayout.PasswordField(GUI.MakeLabel("Activation Code"), m_licenseActivateData.Password); InspectorGUI.SelectFolder(GUI.MakeLabel("License File Directory"), LicenseDirectory, "License file directory", newDirectory => { newDirectory = newDirectory.PrettyPath(); if (string.IsNullOrEmpty(newDirectory)) { newDirectory = "Assets"; } if (!Directory.Exists(newDirectory)) { Debug.LogWarning($"Invalid license directory: {newDirectory} - directory doesn't exist."); return; } else if (!IO.Utils.IsValidProjectFolder(newDirectory)) { Debug.LogWarning($"Invalid license directory: {newDirectory} - directory has to be in the project."); return; } LicenseDirectory = newDirectory; }); using (new GUI.EnabledBlock(UnityEngine.GUI.enabled && m_licenseActivateData.Id.Length > 0 && m_licenseActivateData.Password.Length > 0)) { // It isn't possible to press this button during activation. if (UnityEngine.GUI.Button(EditorGUI.IndentedRect(EditorGUILayout.GetControlRect()), GUI.MakeLabel(AGXUnity.LicenseManager.IsBusy ? "Activating..." : "Activate"), InspectorEditor.Skin.Button)) { AGXUnity.LicenseManager.ActivateAsync(System.Convert.ToInt32(m_licenseActivateData.Id), m_licenseActivateData.Password, LicenseDirectory, success => { if (success) { m_licenseActivateData = IdPassword.Empty(); } else { Debug.LogError("License Error: ".Color(Color.red) + AGXUnity.LicenseManager.LicenseInfo.Status); } StartUpdateLicenseInformation(); UnityEngine.GUI.FocusControl(""); }); } } } }
public IActionResult Post([FromBody] IdPassword usuario) { return(Ok(_uadminManager.AddKey(usuario))); }
//this method get the details of a particular user public IActionResult Check([FromBody] IdPassword modal) { return(Ok(_context.Check(modal))); }