//example public static IRestResponse RegisterUSer(string email, string password) { string queryBody; registerUser cus = new registerUser(); cus.email = email; cus.password = password; queryBody = SimpleJson.SerializeObject(cus); _commonPage.APIResponse = CommonAPICall.APICall(Method.POST, "api/register", queryBody); return(_commonPage.APIResponse); }
public int insertUser(registerUser reg) { dbcon obj = new dbcon(); SqlParameter[] objParams = new SqlParameter[6]; objParams[0] = new SqlParameter("@UserName", reg.UserName); objParams[1] = new SqlParameter("@Password", reg.Password); objParams[2] = new SqlParameter("@FirstName", reg.FirstName); objParams[3] = new SqlParameter("@LastName", reg.LastName); objParams[4] = new SqlParameter("@Email", reg.Email); objParams[5] = new SqlParameter("@Mobile", reg.MobileNo); //objParams[6] = new SqlParameter("@Result", reg.result); int b = obj.ExecuteNonQuery("insertUser", objParams); return(b); }
public async Task <IActionResult> register(registerUser user) { // [FromBody] // if (!ModelState.IsValid) //{ // return BadRequest(ModelState); //} user.name = user.name.ToLower(); if (await _repo.userExists(user.name)) { return(BadRequest("UserName Is Exsist")); } var createUser = new User { userName = user.name }; var createdName = await _repo.register(createUser, user.password); return(StatusCode(201)); }
public IActionResult newUser(registerUser input) { if (ModelState.IsValid) { // If a User exists with provided email if (dbContext.Users.Any(u => u.email == input.email)) { // Manually add a ModelState error to the Email field, with provided error message ModelState.AddModelError("email", "Email already in use!"); return(View("Login")); } //Password Hasher! PasswordHasher <registerUser> Hasher = new PasswordHasher <registerUser>(); input.password = Hasher.HashPassword(input, input.password); input.created_at = DateTime.Now; input.updated_at = DateTime.Now; User user = new User(); user.first_name = input.first_name; user.last_name = input.last_name; user.email = input.email; user.password = input.password; dbContext.Users.Add(user); dbContext.SaveChanges(); //Savein Session and redirect to Index. HttpContext.Session.SetInt32("uId", user.uId); return(RedirectToAction("Index", "Home")); } else { // Error Messages ONLY work with View method. return(View("Login")); } }
public GeoLocationMessageControl(registerUser callBack, activatePage callBack2) { InitializeComponent(); registerUserFn = callBack; activatePageFn = callBack2; }
protected void btnreg_Click(object sender, EventArgs e) { registerUser reg = new registerUser(); dbcon obj = new dbcon(); string querycount = "Select Count(*) FROM users where UserName ='******'"; //string querycount = "Select Count(*) FROM users where UserName ='******'"; //SqlCommand cmd = new SqlCommand(); // cmd.Parameters.AddWithValue("@UserName", txtUserName.Text); int count = obj.ohh(querycount); if (count > 0) { lblreg.Text = "The User Already Exits"; } else { //registerUser reg = new registerUser(); reg.UserName = txtUserName.Text; reg.Password = txtPassword.Text; reg.FirstName = txtfirstname.Text; reg.LastName = txtlastname.Text; reg.Email = txtemail.Text; reg.MobileNo = txtmobileno.Text; int b = reg.insertUser(reg); if (b == 1) { //lblreg.Text = "User Registration Successful"; //lblreg.Text = reg.result; } else { // lblreg.Text = "Oh Their is Some Problem, Come back Lator"; //lblreg.Text = reg.result; } ecprops _user = new ecprops(); dbcon dbo = new dbcon(); _user = dbo.CheckUser(txtUserName.Text); if (_user != null) { if (_user.Password == txtPassword.Text) { FormsAuthenticationTicket Authticket = new FormsAuthenticationTicket( 1, txtUserName.Text, DateTime.Now, DateTime.Now.AddMinutes(30), CheckBox1.Checked, _user.RoleName, FormsAuthentication.FormsCookiePath); string hash = FormsAuthentication.Encrypt(Authticket); HttpCookie Authcookie = new HttpCookie(FormsAuthentication.FormsCookieName, hash); if (Authticket.IsPersistent) { Authcookie.Expires = Authticket.Expiration; } Response.Cookies.Add(Authcookie); string returnUrl = Request.QueryString["ReturnUrl"]; if (returnUrl == null) { returnUrl = "Default.aspx"; } Response.Redirect(returnUrl); } else { lblreg.Text = "Password does'nt match."; } } else { lblreg.Text = "User not exists."; } } }