public bool Authenticate(string username, string password) { IUser user = _userFactory.Get(username); return(user != null && user.CheckPassword(password)); }
public IList <ProjectModel> GetForUser(string username) { IUser user = _userFactory.Get(username); if (user == null) { return(null); } IList <ProjectModel> result = new List <ProjectModel>(); IList <IProject> projects = user.GetProjects(); foreach (IProject project in projects) { ProjectModel model = new ProjectModel { Id = project.Id, Code = project.Code, YouTrackQuery = project.YouTrackQuery, YouTrackUrl = project.YouTrackUrl }; result.Add(model); } return(result); }
public string Authenticate(string username, string password, string secret) { IUser user = _userFactory.Get(username); bool correctPassword = user.CheckPassword(password); // ignore password check for test if (user == null) { return(null); } // authentication successful so generate jwt token var tokenHandler = new JwtSecurityTokenHandler(); var key = Encoding.ASCII.GetBytes(secret); var tokenDescriptor = new SecurityTokenDescriptor { Subject = new ClaimsIdentity(new Claim[] { new Claim(ClaimTypes.NameIdentifier, user.Id.ToString()), new Claim(ClaimTypes.Name, user.Username) }), Expires = DateTime.UtcNow.AddDays(7), SigningCredentials = new SigningCredentials(new SymmetricSecurityKey(key), SecurityAlgorithms.HmacSha256Signature) }; var token = tokenHandler.CreateToken(tokenDescriptor); string tokenString = tokenHandler.WriteToken(token); return(tokenString); }
public UserModel Get(string username) { IUser user = _userFactory.Get(username); if (user == null) { return(null); } UserModel result = new UserModel { Username = user.Username, Firstname = user.Firstname, Lastname = user.Lastname, Email = user.Email }; return(result); }
public int?Authenticate(string username, string password) { IUser user = _userFactory.Get(username); if (user != null && user.CheckPassword(password)) { return(user.Id); } return(null); }
public UserModel Get(int id) { IUser user = _userFactory.Get(id); if (user == null) { return(null); } UserModel result = new UserModel { Id = user.Id, Username = user.Username, Firstname = user.Firstname, Lastname = user.Lastname, Email = user.Email, IsAdmin = user.IsAdmin }; return(result); }
public TeamMember(ProjectUser projectUser, IIssueEstimationRepository issueEstimationRepository, IProjectFactory projectFactory, IUserFactory userFactory) { _projectUser = projectUser; _issueEstimationRepository = issueEstimationRepository; User = userFactory.Get(projectUser.User); Project = projectFactory.Get(projectUser.Project); }
public async Task <IActionResult> Post(CreateUserViewModel user) { try { #region Get File From Ziggeo var video = new Video(); using (var client = new HttpClient()) using (var request = new HttpRequestMessage(HttpMethod.Get, user.VideoUrl)) { var contentStream = await(await client.SendAsync(request)).Content.ReadAsStreamAsync(); var bytesFiles = contentStream.ToBytes(); video.File = new CommonFile { File = bytesFiles, Name = user.FileName }; } #endregion #region Save File At azure var azureFileService = _azureFileHandlerFactory.GetService( _azureSettings.ConnectionString, _azureSettings.VideoContainer ); user.AzureVideoUrl = await azureFileService.SaveFileAsync(video.File); #endregion #region Save User var userDal = _userFactory.Get(user); _unitOfWork.Users.Add(userDal); _unitOfWork.SaveChanges(); #endregion #region Get VideoID var videoMedia = await _videoAnalizer.PostVideo(user.AzureVideoUrl); #endregion return(Json(new { userId = userDal.Id, videoId = videoMedia.Id })); } catch (Exception e) { return(StatusCode((int)HttpStatusCode.InternalServerError, e)); } }
public IUser Get(string name) { return(m_factory.Get(name)); }