public async Task<HttpResponseMessage> SaveCustomer(Request<DtoCustomer> c) { if (!AuthenticationLogic.IsTokenCorrect(c.Token, c.Login)) return new HttpResponseMessage(HttpStatusCode.Unauthorized); var response = Request.CreateResponse(HttpStatusCode.OK, await new CustomerLogic().SaveCustomer(c.Content)); return response; }
/// <summary> /// dto to Data Access Conversion /// </summary> /// <param name="employee">dto Employee</param> /// <returns>Data Access Employee</returns> public static Employee DtoToDataAccess(DtoEmployee employee) { var e = new Employee { id = employee.Id, name = employee.Name, surname = employee.Surname, email = employee.Email, phoneNumber = employee.PhoneNumber, icePhoneNumber = employee.IcePhoneNumber, personalIdentityNumber = employee.PersonalIdentityNumber, identityCardNumber = employee.IdentityCardNumber, city = employee.City, street = employee.Street, postalCode = employee.PostalCode, houseNumber = employee.HouseNumber, apartmentNumber = employee.ApartmentNumber, description = employee.Description, supervisorID = employee.SupervisorId, positionID = employee.Position.Id, password = AuthenticationLogic.HashPassword(employee.Password, employee) }; return(e); }
public async Task<HttpResponseMessage> GetCustomer(Request<int> id) { if (!AuthenticationLogic.IsTokenCorrect(id.Token, id.Login)) return new HttpResponseMessage(HttpStatusCode.Unauthorized); var response = Request.CreateResponse(HttpStatusCode.OK, await new CustomerLogic().GetCustomer(id.Content)); return response; }
protected void btnRegister_Click(object sender, EventArgs e) { // read values from the text fields string username = txtUsername.Text.Trim(); string password = Encryptor.EncryptText(txtPassword.Text.Trim()); string passwordCon = Encryptor.EncryptText(txtConfirmPassword.Text.Trim()); if (!password.Equals(passwordCon)) { lblMessage.Text = "Passwords do not match. Please try again."; lblMessage.ForeColor = System.Drawing.Color.Red; return; } AuthenticationLogic al = new AuthenticationLogic(); User user = al.GetUserByName(username); if (user != null) { lblMessage.Text = "Username is taken. Please try again."; lblMessage.ForeColor = System.Drawing.Color.Red; return; } if (al.CreateUser(new User(0, username, password, "Member", "")) == 1) { lblMessage.Text = "Registration Complete!"; lblMessage.ForeColor = System.Drawing.Color.Green; return; } }
public async Task <ActionResult> InitiateConsent(ServicePrincipalModel principalModel) { return(await SafeExecuteView(async() => { // Validate the basic input data if (string.IsNullOrEmpty(principalModel.ConsentAzureAdTenantDomainOrId)) { ModelState.AddModelError("ConsentAzureAdTenantDomainOrId", "Please enter a Tenant ID (GUID) or a Tenant Domain (e.g. xyz.onmicrosoft.com) for initiaiting the consent!"); } if (ModelState.IsValid) { // Start the consent flow for the target tenant var redirectUrl = string.Format("{0}{1}", Request.Url.GetLeftPart(UriPartial.Authority), Url.Action("CatchConsentResult")); var authorizationUrl = await AuthenticationLogic.ConstructConsentUrlAsync ( principalModel.ConsentAzureAdTenantDomainOrId, AuthenticationConfig.ConfiguratinItems.ManagementAppUri, redirectUrl ); return Redirect(authorizationUrl); } else { principalModel.SubmitConsentEnabled = true; principalModel.SubmitSpEnabled = false; principalModel.SubmitAdminConsentEnabled = false; principalModel.UserMessage = "Please fix errors and try initiating the consent again!"; return View("Index", principalModel); } })); }
public async Task <ActionResult> InitiateAdminConsent(ServicePrincipalModel principalModel) { return(await SafeExecuteView(async() => { // Validate the basic input data if (string.IsNullOrEmpty(AuthenticationConfig.SessionItems.GraphTargetTenant)) { throw new Exception("Cannot initate Admin Consent without a default tenant known!"); } else { // Start the consent flow for the target tenant var redirectUrl = string.Format("{0}{1}", Request.Url.GetLeftPart(UriPartial.Authority), Url.Action("CatchConsentResult")); var authorizationUrl = await AuthenticationLogic.ConstructConsentUrlAsync ( AuthenticationConfig.SessionItems.GraphTargetTenant, AuthenticationConfig.ConfiguratinItems.ManagementAppUri, redirectUrl, true ); return Redirect(authorizationUrl); } })); }
static public Guid OpenExportProcess(Guid tenantId, ShippingExportDC dc) { if (GetExportProcessbyContractId(dc.Id) != null) { return(Guid.Empty); } Dictionary <string, object> parameters = new Dictionary <string, object>(); parameters.Add("TenantId", tenantId); parameters.Add("ObjectId", dc.Id); parameters.Add("Number", dc.Number); string textUpn = AuthenticationLogic.GetUpnByUserId((Guid)dc.Creator); parameters.Add("Creator", textUpn); WorkflowDefinition workflowDef = WorkflowLogic.GetWorkflowDefinition(tenantId, (int)ProcessTypes.ShippingExport); parameters.Add("InternalWorkflowType", (int)ProcessTypes.ShippingExport); System.Xml.XmlReader xomlReader = System.Xml.XmlReader.Create(new StringReader(workflowDef.Xoml)); System.Xml.XmlReader rulesReader = string.IsNullOrEmpty(workflowDef.Rules)?null:System.Xml.XmlReader.Create(new StringReader(workflowDef.Rules)); WorkflowInstance workflowInstance = Runtime.CreateWorkflow(xomlReader, rulesReader, parameters); workflowInstance.Start(); RunWorkflowInScheduler(workflowInstance.InstanceId); return(workflowInstance.InstanceId); }
/// <summary> /// Sign in user /// </summary> /// <param name="model">Model</param> /// <returns>View</returns> public async Task <ActionResult> SignIn(SignInViewModel model) { string error = null; if (string.IsNullOrWhiteSpace(model.Email) == false && string.IsNullOrWhiteSpace(model.Password) == false) { var user = await AuthenticationLogic.AuthenticateCustomer(new DtoSignIn { EMail = model.Email, Password = model.Password }); if (user != "Unauthorized") { FormsAuthentication.RedirectFromLoginPage(model.Email, true); } else { error = "Błąd podczas logowania"; } } error = "Błąd podczas logowania"; return(View(new SignInViewModel() { ErrorText = error })); }
private void LoginForm_KeyDown(object sender, KeyEventArgs e) { if (e.KeyCode == Keys.Enter) { var success = AuthenticationLogic.Login(txtUserName.Text, txtPassword.Text); DisableFields(); } }
private void btnLogin_Click(object sender, EventArgs e) { //txtUserName.Text = "master"; //txtPassword.Text = "123456"; var response = AuthenticationLogic.Login(txtUserName.Text, txtPassword.Text, OnLoginSuccess, OnLoginFailed); DisableFields(); }
public AuthenticationController(AuthenticationLogic authorizationLogic, LogLogic logLogic, JwtLogic jwtLogic, ControllerHelper controllerHelper) { _authorizationLogic = authorizationLogic; _logLogic = logLogic; _jwtLogic = jwtLogic; _controllerHelper = controllerHelper; }
public static async Task <List <Models.Cars.CarProperty> > Get(Guid token, int carId) { AuthenticationLogic.CheckTokenInfo(token); using (var db = new DataAccess.CaraxEntitiy()) { return(await db.CarProperties?.Where(q => q.CarId == carId)?.ToListAsync()); } }
public async Task<HttpResponseMessage> GetCustomers(Request<string> filter) { var customerLogic = new CustomerLogic(); if (!AuthenticationLogic.IsTokenCorrect(filter.Token, filter.Login)) return new HttpResponseMessage(HttpStatusCode.Unauthorized); var response = Request.CreateResponse(HttpStatusCode.OK, await customerLogic.GetCustomers(filter.Content)); return response; }
public string[] GetUsers(string tenantName) { if (string.IsNullOrEmpty(tenantName)) { throw new ArgumentNullException("tenantName"); } return(AuthenticationLogic.GetUsers(tenantName)); }
public string[] FindUsers(string tenantName, string usernameToMatch) { if (string.IsNullOrEmpty(tenantName)) { throw new ArgumentNullException("tenantName"); } return(AuthenticationLogic.FindUsers(tenantName, usernameToMatch)); }
public string GetUpnByUserId(Guid id) { if (id == Guid.Empty) { throw new ArgumentNullException("id"); } return(AuthenticationLogic.GetUpnByUserId(id)); }
protected bool CheckMemberUserIsNotAuthorized(string id) { var userInfo = AuthenticationLogic.CheckTokenInfo(GetToken()); if (userInfo.Username.IsNumeric()) { return(userInfo.Username != id); } return(false); }
public AuthenticationController( CursedAuthenticationContext db, [FromServices] IErrorHandlerFactory errorHandlerFactory, [FromServices] IGenPasswordHash genPassHash, [FromServices] ILogProvider <CursedAuthenticationContext> logProvider) { logic = new AuthenticationLogic(db); logicValidation = new AuthenticationLogicValidation(db, errorHandlerFactory, genPassHash); this.logProvider = logProvider; }
public async Task <HttpResponseMessage> SaveEmployee(Request <DtoEmployee> e) { if (!AuthenticationLogic.IsTokenCorrect(e.Token, e.Login)) { return(new HttpResponseMessage(HttpStatusCode.Unauthorized)); } var response = Request.CreateResponse(HttpStatusCode.OK, await new EmployeeLogic().SaveEmployee(e.Content)); return(response); }
public async Task <HttpResponseMessage> SavePosition(Request <DtoPosition> p) { if (!AuthenticationLogic.IsTokenCorrect(p.Token, p.Login)) { return(new HttpResponseMessage(HttpStatusCode.Unauthorized)); } var response = Request.CreateResponse(HttpStatusCode.OK, await new PositionLogic().SavePosition(p.Content)); return(response); }
public async Task <HttpResponseMessage> GetPosition(Request <int> id) { if (!AuthenticationLogic.IsTokenCorrect(id.Token, id.Login)) { return(new HttpResponseMessage(HttpStatusCode.Unauthorized)); } var response = Request.CreateResponse(HttpStatusCode.OK, await new PositionLogic().GetPosition(id.Content)); return(response); }
public async Task <HttpResponseMessage> GetSports(Request <int> r) { if (!AuthenticationLogic.IsTokenCorrect(r.Token, r.Login)) { return(new HttpResponseMessage(HttpStatusCode.Unauthorized)); } var response = Request.CreateResponse(HttpStatusCode.OK, await new SportTypeLogic().GetAllSportTypes()); return(response); }
public async Task <HttpResponseMessage> AddCourse(Request <DtoService> s) { if (!AuthenticationLogic.IsTokenCorrect(s.Token, s.Login)) { return(new HttpResponseMessage(HttpStatusCode.Unauthorized)); } var response = Request.CreateResponse(HttpStatusCode.OK, await new ServiceLogic().AddService(s.Content)); return(response); }
public async Task <HttpResponseMessage> GetServices(Request <ServiceFilter> request) { if (!AuthenticationLogic.IsTokenCorrect(request.Token, request.Login)) { return(new HttpResponseMessage(HttpStatusCode.Unauthorized)); } var response = Request.CreateResponse(HttpStatusCode.OK, await new ServiceLogic().GetServices(request.Content)); return(response); }
public async Task <HttpResponseMessage> GetEmployees(Request <string> filter) { if (!AuthenticationLogic.IsTokenCorrect(filter.Token, filter.Login)) { return(new HttpResponseMessage(HttpStatusCode.Unauthorized)); } var response = Request.CreateResponse(HttpStatusCode.OK, await new EmployeeLogic().GetEmployees(filter.Content)); return(response); }
public async Task <HttpResponseMessage> EnrolCourse(Request <EnrolRequest> request) { if (!AuthenticationLogic.IsTokenCorrect(request.Token, request.Login)) { return(new HttpResponseMessage(HttpStatusCode.Unauthorized)); } var response = Request.CreateResponse(HttpStatusCode.OK, await new ServiceLogic().EnrolCourse(request.Content.CustomerId, request.Content.ServiceId)); return(response); }
public async Task <HttpResponseMessage> SaveSportType(Request <DtoSportType> st) { if (!AuthenticationLogic.IsTokenCorrect(st.Token, st.Login)) { return(new HttpResponseMessage(HttpStatusCode.Unauthorized)); } var response = Request.CreateResponse(HttpStatusCode.OK, await new SportTypeLogic().SaveSportType(st.Content)); return(response); }
public static async Task <bool> Remove(Guid token, string departmentCode, int carId, int serviceId) { AuthenticationLogic.CheckTokenInfo(token); using (var db = new DataAccess.CaraxEntitiy()) { var find = db.CarInServices.First(q => q.CarId == carId && q.CarServiceId == serviceId); db.CarInServices.Remove(find); return(await db.SaveChangesAsync() > 0); } }
public static async Task <bool> Create(Guid token, string departmentCode, Models.Cars.CarInService carInService) { AuthenticationLogic.CheckTokenInfo(token); using (var db = new DataAccess.CaraxEntitiy()) { var find = db.CarInServices.First(q => q.CarId == carInService.CarId && q.CarServiceId == carInService.CarServiceId); await db.CarInServices.AddAsync(carInService); return(await db.SaveChangesAsync() > 0); } }
public static Users DtoToDataAccess(DtoUser d) { return(new Users { id = d.Id, login = d.Login, cardId = d.CardId, password = AuthenticationLogic.HashPassword(d.Password, d.Login), averageScore = d.AverageScore, isAdmin = d.IsAdmin }); }
public void TestSignInUserUserNullPasswordThrowsArgumentNullException() { var logic = new AuthenticationLogic(); Exception exception = null; try { logic.SignInUser("admin", null); } catch (Exception ex) { exception = ex; } Assert.IsNotNull(exception); Assert.AreEqual( typeof(ArgumentNullException), exception.GetType()); }