Exemplo n.º 1
0
        public ActionResult Index(Models.Login login)
        {
            // UserStore and UserManager manages data retreival.
            UserStore <IdentityUser>   userStore = new UserStore <IdentityUser>();
            UserManager <IdentityUser> manager   = new UserManager <IdentityUser>(userStore);
            IdentityUser identityUser            = manager.Find(login.UserName,
                                                                login.Password);

            if (ModelState.IsValid)
            {
                if (identityUser != null)
                {
                    IAuthenticationManager authenticationManager
                        = HttpContext.GetOwinContext().Authentication;
                    authenticationManager
                    .SignOut(DefaultAuthenticationTypes.ExternalCookie);

                    var identity = new ClaimsIdentity(new[] {
                        new Claim(ClaimTypes.Name, login.UserName),
                    },
                                                      DefaultAuthenticationTypes.ApplicationCookie,
                                                      ClaimTypes.Name, ClaimTypes.Role);
                    // SignIn() accepts ClaimsIdentity and issues logged in cookie.
                    authenticationManager.SignIn(new AuthenticationProperties
                    {
                        IsPersistent = false
                    }, identity);
                    return(RedirectToAction("SecureArea", "Home"));
                }
            }
            return(View());
        }
Exemplo n.º 2
0
        public ActionResult Login(Models.Login login)
        {
            if (ModelState.IsValid)
            {
                var us = db.People.Where(x => x.Username == login.User).FirstOrDefault();
                if (us != null && us.Password == new RexaHash().MD5(login.Pass))
                {
                    TempData["Message"] = "ورود موفق به سیستم!";
                    Session["UserId"]   = us.Id;
                }
                else
                {
                    TempData["Message"] = "نام کاربری یا کلمه ی عبور صحیح نیست!";
                }

                if (ControllerContext.IsChildAction)
                {
                    ControllerContext.HttpContext.Response.Redirect(ControllerContext.HttpContext.Request.Url.ToString());
                }
                else
                {
                    return(RedirectToAction("Index", "Home"));
                }
            }
            if (ControllerContext.IsChildAction)
            {
                return(PartialView());
            }
            return(View());
        }
Exemplo n.º 3
0
 public ActionResult Login(Models.Login login)
 {
     try
     {
         if (ModelState.IsValid)
         {
             ServiceUsuariosClient service = new ServiceUsuariosClient();
             Usuario usuario = service.AutenticarUsuario(int.Parse(login.Usuario), login.Password);
             if (usuario == null)
             {
                 throw new Exception("Usuario incorrecto.");
             }
             FormsAuthentication.SetAuthCookie(usuario.nombre, true);
             return(RedirectToAction("Index", "Home"));
         }
         else
         {
             throw new Exception("Datos no válidos.");
         }
     }
     catch (Exception ex)
     {
         ModelState.AddModelError("", ex.Message);
     }
     return(View(login));
 }
Exemplo n.º 4
0
        private void btnLogar_Click(object sender, EventArgs e)
        {
            string cpf   = txbCPFLogin.Text;
            string senha = txbSenhaLogin.Text;

            Models.Login login = new Models.Login();

            login.Cpf   = cpf;
            login.Senha = senha;

            if (login.logaCandidato())
            {
                this.Hide();

                string CPF = txbCPFLogin.Text;

                Models.Candidato candidato = new Models.Candidato();

                candidato.Cpf = CPF;

                candidato.pegarDados();

                Forms.Paineis.PaineisCandidato.PainelCandidato painelCandidato = new Forms.Paineis.PaineisCandidato.PainelCandidato(candidato.Cpf, candidato.Nome);

                painelCandidato.ShowDialog();
            }
            else
            {
                MessageBox.Show("CPF ou Senha incorretos!!", "Erro", MessageBoxButtons.OK, MessageBoxIcon.Warning);
            }
        }
Exemplo n.º 5
0
        public JsonResult porcentaje()
        {
            Models.principalP  actividad = Session["usuario3"] as Models.principalP;
            Models.Actividades sec1      = Session["seccion1"] as Models.Actividades;
            Models.Login       usr       = Session["usuario"] as Models.Login;
            Actividades        usu       = new Actividades();
            DataTable          datos     = null;
            var x = 2;

            DataTable datos1 = usu.Buscar_porcentaje_seccion(actividad.codigo_actividad, usr.usuario);

            usu.id_curso_actividad = Convert.ToInt32(datos1.Rows[0]["id tabla"].ToString());
            Session["seccion1"]    = usu;

            if (Convert.ToDouble(datos1.Rows[0]["porcentaje"].ToString()) < 100)
            {
                datos       = usu.Buscar_cantidad_secciones(actividad.codigo_actividad);
                usu.seccion = Convert.ToInt32(datos.Rows[0]["numero secciones"].ToString());
                usu.cont_seccion++;
                Session["seccion1"] = usu;
                int countseccion = Convert.ToInt32(datos1.Rows[0]["seccion"].ToString());
                countseccion++;

                if (countseccion <= Convert.ToInt32(datos.Rows[0]["numero secciones"].ToString()))
                {
                    double porce = (countseccion * 100) / Convert.ToInt32(datos.Rows[0]["numero secciones"].ToString());
                    if (countseccion == Convert.ToInt32(datos.Rows[0]["numero secciones"].ToString()))
                    {
                        usu.Actualizar_porcentaje_estado(Convert.ToInt32(actividad.codigo_actividad), usu.id_curso_actividad);
                    }
                    usu.Actualizar_porcentaje(porce, Convert.ToInt32(actividad.codigo_actividad), countseccion, usu.id_curso_actividad);
                }
            }
            return(Json(x));
        }
Exemplo n.º 6
0
        public ActionResult login(Models.Login loginModel, string returnUrl)
        {
            if (ModelState.IsValid)
            {
                Models.MyIdentityUser user = userManager.Find(loginModel.UserName, loginModel.Password);

                if (user != null)
                {
                    IAuthenticationManager authenticationManager = HttpContext.GetOwinContext().Authentication;
                    authenticationManager.SignOut(DefaultAuthenticationTypes.ExternalCookie);

                    ClaimsIdentity identity = userManager.CreateIdentity(user, DefaultAuthenticationTypes.ApplicationCookie);

                    AuthenticationProperties props = new AuthenticationProperties();
                    props.IsPersistent = loginModel.RememberMe;

                    authenticationManager.SignIn(props, identity);

                    if (Url.IsLocalUrl(returnUrl))
                    {
                        return(Redirect(returnUrl));
                    }
                    else
                    {
                        return(Redirect(Url.Content(string.Format("~/{0}", user.UserName))));
                    }
                }
                else
                {
                    ModelState.AddModelError("invalid", "Invalid username or password");
                }
            }

            return(View(loginModel));
        }
Exemplo n.º 7
0
        public async Task <ActionResult> Login(Models.Login model, string returnUrl)
        {
            try
            {
                // Verification.
                if (ModelState.IsValid)
                {
                    var auth = new FirebaseAuthProvider(new FirebaseConfig(ApiKey));
                    var ab   = await auth.SignInWithEmailAndPasswordAsync(model.Email, model.Password);

                    string token = ab.FirebaseToken;
                    var    user  = ab.User;
                    if (token != "")
                    {
                        this.SignInUser(user.Email, token, false);
                        System.Web.Security.FormsAuthentication.Authenticate(user.Email, token);
                        return(this.RedirectToLocal(returnUrl));
                        //return RedirectToAction("Home");
                    }
                    else
                    {
                        // Setting.
                        ModelState.AddModelError(string.Empty, "Invalid username or password.");
                    }
                }
            }
            catch (Exception ex)
            {
                // Info
                Console.Write(ex);
            }

            // If we got this far, something failed, redisplay form
            return(this.View(model));
        }
        public async Task <IActionResult> SignIn([FromBody] Models.Login args)
        {
            var buser = endUserBusiness;

            var user = await buser.GetByEmail(args.Email);

            if (user != null)
            {
                // Check if active
                if (user.DateInactive != null)
                {
                    ModelState.AddModelError(string.Empty, "Account is inactive.");
                    TempData["notice"] = "Account is inactive.";
                    return(View(args));
                }

                // Check password
                var salt      = user.PasswordSalt;
                var saltBytes = Convert.FromBase64String(salt);

                if (Core.Crypto.Hash(args.Password, saltBytes) == user.PasswordHash)
                {
                    // Successful log in
                    user.LastSessionId = Guid.NewGuid().ToString();
                    user.LastLoginDate = DateTime.Now;
                    await buser.Edit(user);

                    return(Json(Core.JWT.GenerateToken(user.UserId, Core.Setting.Configuration.GetValue <string>("JWT:Secret"))));
                }
            }

            return(Unauthorized());
        }
        public ActionResult Contractorlogin(Models.Login model)
        {
            ViewBag.Message = "Your Contractorlogin page.";
            var password = Encrypt(model.Password).ToString();

            var user = db.Login
                       .Where(b => b.Email == model.Email.ToString() && b.Password == password)
                       .FirstOrDefault();


            if (user != null)
            {
                var profile = db.Contractors.Where(b => b.ID == user.ProfileId)
                              .FirstOrDefault();
                var states = samedayservicez.Utils.Extensions.GetStatesList();

                profile.States = GetSelectListItems(states);

                return(View("ContractorProfileConfirm", profile));
            }
            else
            {
                return(View("Contractorlogin", model));
            }
        }
Exemplo n.º 10
0
        public ActionResult ResetPassword(Guid?id)
        {
            var objResetPassword = (from liga in db.mResetPassword
                                    where liga.Id == id
                                    select liga).FirstOrDefault();

            ViewBag.errorResetPassword = string.Empty;

            if (objResetPassword != null)
            {
                if (objResetPassword.EstatusId == 5)
                {
                    return(View(objResetPassword));
                }
                else
                {
                    ViewBag.error = Resources.Autentificacion.msgLigaNoActiva;
                    ViewBag.successChangePassword = string.Empty;
                    var objLogin = new Models.Login();

                    return(View("Login", objLogin));
                }
            }
            else
            {
                ViewBag.error = Resources.Autentificacion.msgLigaNoExiste;
                ViewBag.successChangePassword = string.Empty;
                var objLogin = new Models.Login();

                return(View("Login", objLogin));
            }
        }
Exemplo n.º 11
0
        void Modification()
        {
            System.Windows.Input.Mouse.OverrideCursor = System.Windows.Input.Cursors.Wait;
            Models.Login _user = WPE.Login.SingleOrDefault(b => b.IDLogin == ActualUser.IDLogin);

            if (_user != null && f.IsYourPassword(T_OldPassword, T_OldPassword.Password, ActualUser, (rm as ResourceManager)))
            {
                if (TB_user.Text != string.Empty)
                {
                    if (f.IsName(TB_user, TB_user.Text.Trim(), (rm as ResourceManager)))
                    {
                        _user.User = TB_user.Text.Trim();
                    }
                }
                if (T_passwd.Password != string.Empty || T_passwdAgain.Password != string.Empty)
                {
                    if (f.IsPassword(T_passwd, T_passwd.Password, (rm as ResourceManager)) && f.IsPasswordAreEqual(T_passwd, T_passwdAgain, T_passwd.Password, T_passwdAgain.Password, (rm as ResourceManager)))
                    {
                        _user.Password = f.Encrypt(T_passwd.Password.Trim());
                    }
                }
                if (TB_email.Text != string.Empty)
                {
                    if (f.IsValidEmail(TB_email, TB_email.Text.Trim(), (rm as ResourceManager)))
                    {
                        _user.EmailAddress = TB_email.Text.Trim();
                    }
                }
                WPE.SaveChanges();
                WPE                    = new Models.WeddingPlannerEntities();
                ActualUser             = _user;
                h.LB_TitleHome.Content = h.LB_TitleHome.Content.ToString().Split(' ')[0] + " " + ActualUser.User.Trim();
            }
            System.Windows.Input.Mouse.OverrideCursor = null;
        }
Exemplo n.º 12
0
        /// <summary>
        /// 得到一个对象实体
        /// </summary>
        public Models.Login GetModel(int id)
        {
            StringBuilder strSql = new StringBuilder();

            strSql.Append("select *");
            strSql.Append(" from tb_user");
            strSql.Append(" where id=@id");
            SqlParameter[] parameters =
            {
                new SqlParameter("@id", SqlDbType.Int, 4)
            };
            parameters[0].Value = id;

            Models.Login model = new Models.Login();
            DataSet      ds    = DbHelperSQL.Query(strSql.ToString(), parameters);

            if (ds.Tables[0].Rows.Count > 0)
            {
                return(DataRowToModel(ds.Tables[0].Rows[0]));
            }
            else
            {
                return(null);
            }
        }
Exemplo n.º 13
0
        public async Task <int> LoginAsync(Models.Login model)
        {
            var exists = await base.Logins.AnyAsync(x => x.UserName == model.UserName);

            if (exists)
            {
                var pass = await base.Logins.FirstAsync(x => x.UserName == model.UserName);

                var decode = Protector.Unprotect(pass.Password);
                if (decode.Trim() == model.Password.Trim())
                {
                    var isLogin = new List <Claim> {
                        new Claim(ClaimTypes.Name, model.UserName),
                        new Claim("Password", model.Password)
                    };
                    var identity      = new ClaimsIdentity(isLogin, "LogedIn");
                    var userPrincipal = new ClaimsPrincipal(new[] { identity });
                    await _httpContextAccessor.HttpContext.SignInAsync(userPrincipal);

                    return(pass.Id);
                }
                return(0);
            }
            return(0);
        }
Exemplo n.º 14
0
 public ActionResult Login(Models.Login model)
 {
     if (ModelState.IsValid)
     {
         var daluser = new DAL.UserDAL();
         var user    = daluser.Login(model);
         if (user != null)
         {
             Session["USER"] = user;
             var sestud  = (Entity.User)Session["USER"];
             int id      = sestud.User_id;
             var dalstud = new DAL.StudentDAL();
             var stud    = dalstud.Searchstud(id);
             if (stud != null)
             {
                 Session["Stud"] = stud;
             }
             var dalteac = new DAL.TeacherDAL();
             var teacher = dalteac.Searchteac(id);
             if (teacher != null)
             {
                 Session["Teacher"] = teacher;
             }
             return(RedirectToAction("Index", "User"));
         }
         else
         {
             Response.Write("<script> alert('ไม่พบผู้ใช้')</script>");
         }
     }
     return(View(model));
 }
Exemplo n.º 15
0
        public ActionResult Logar(Models.Login Login)
        {
            if (ModelState.IsValid)
            {
                BD.IGERENCEEntities objBD = new BD.IGERENCEEntities();

                var objLogin = (from BD.AGCF_USUARIO u in objBD.AGCF_USUARIO where u.DESLOGIN.ToUpper() == Login.Usuario.ToUpper() && u.DESSENHA == Login.Senha select u).FirstOrDefault();

                if (objLogin != null)
                {
                    Models.Login objLoginSessao = new Login()
                    {
                        Email         = objLogin.DESEMAIL,
                        Identificador = objLogin.IDUSUARIO,
                        Nome          = objLogin.DESNOME,
                        Usuario       = objLogin.DESLOGIN
                    };

                    SetLogOnSessionModel(objLoginSessao);

                    return(RedirectToAction("Index", "Principal"));
                }
                else
                {
                    ModelState.AddModelError("", "Usuario ou senha incorretos.");
                }
            }
            else
            {
                ModelState.AddModelError("", "Dados informados não estão corretos.");
            }

            return(View("Index", Login));
        }
Exemplo n.º 16
0
        public ActionResult ManageUserProfile(Models.Login userInfo)
        {
            if (Request.IsAuthenticated && User.Identity.Name != "" && ModelState.IsValid)
            {
                userInfo.Username = User.Identity.Name;
                userInfo.Password = CalculateMD5Hash(userInfo.Password);
                var existingUser = from c in dataContext.Logins
                                   where (c.Username.ToLower() == userInfo.Username.ToLower() && c.Password == userInfo.Password)
                                   select c;
                if (existingUser.Count() != 0)
                {
                    existingUser.FirstOrDefault().FullName = userInfo.FullName;
                    existingUser.FirstOrDefault().Password = CalculateMD5Hash(userInfo.NewPassword);

                    dataContext.SubmitChanges();
                }
                else
                {
                    ViewBag.Message = "Username or password is incorrect!";
                }
            }
            else
            {
                ViewBag.Message = "Please login to continue!";
            }
            return(View());
        }
Exemplo n.º 17
0
        public Login verificar_usuario_modelo(string Usuario)
        {
            string id;
            string pass;
            Login  Retorno = new Models.Login();

            ds = new DataSet();
            conn.Open();
            SqlCommand     cmd  = new SqlCommand("select id,tipo from usuario where email='" + Usuario + "';", conn);
            SqlDataAdapter adap = new SqlDataAdapter(cmd);

            adap.Fill(ds, "tabla");
            try
            {
                id  = ds.Tables["tabla"].Rows[0]["id"].ToString();
                Rol = ds.Tables["tabla"].Rows[0]["tipo"].ToString();
                SqlCommand     cmd2  = new SqlCommand("select pass from contraseña where usuario_id=" + id + ";", conn);
                SqlDataAdapter adap2 = new SqlDataAdapter(cmd2);
                ds.Clear();
                adap2.Fill(ds, "tabla");
                pass = ds.Tables["tabla"].Rows[0]["pass"].ToString();

                conn.Close();
                Retorno.Correo   = Usuario;
                Retorno.Password = pass;
                Retorno.Rol      = Rol;
            }
            catch (Exception e)
            {
                string a = e.Message;
            }
            return(Retorno);
        }
Exemplo n.º 18
0
 public ActionResult Registration(BloodDonorRegistration br)
 {
     if (ModelState.IsValid)
     {
         DAS.Models.BloodDonor bd = new Models.BloodDonor()
         {
             Name                = br.Name,
             MobileNo            = br.MobileNo,
             Email               = br.Email,
             Gender              = br.Gender,
             BloodGroupId        = br.BloodGroupId,
             cityId              = br.CityId,
             AreaId              = br.AreaId,
             AdditionalAddress   = br.AdditionalAddress,
             isRequested         = false,
             isConfirmed         = false,
             LastBloodDonateTime = br.LastBloodDonateTime
         };
         db.BloodDonors.Add(bd);
         DAS.Models.Login l = new Models.Login();
         l.Email    = br.Email;
         l.Password = br.Password;
         l.Role     = "BD";
         db.Logins.Add(l);
         db.SaveChanges();
         return(RedirectToAction("HomePage"));
     }
     ViewBag.BloodGroupId = new SelectList(db.BloodGroups, "Id", "Name");
     ViewBag.CityId       = new SelectList(db.Cities, "ID", "Name");
     ViewBag.AreaId       = new SelectList(db.Areas, "ID", "Name");
     return(View(br));
 }
        public ActionResult Registration(DoctorRegistration dr)
        {
            if (ModelState.IsValid)
            {
                DAS.Doctor d = new Doctor()
                {
                    Name         = dr.Name,
                    Designation  = dr.Designation,
                    SpecialityId = dr.SpecialityId,
                    Gender       = dr.Gender,
                    MobileNo     = dr.MobileNo,
                    Email        = dr.Email,
                    BMDCNo       = dr.BMDCNo,
                    Description  = dr.Description,
                    Degree_Spec  = dr.Description
                };
                db.Doctors.Add(d);

                DAS.Models.Login l = new Models.Login();
                l.Email    = dr.Email;
                l.Password = dr.Password;
                l.Role     = "D";

                db.Logins.Add(l);

                db.SaveChanges();
                ViewBag.SpecialityId = new SelectList(db.Specialities, "Id", "Name");
                return(View());
            }
            ViewBag.SpecialityId = new SelectList(db.Specialities, "Id", "Name");
            return(View());
        }
Exemplo n.º 20
0
        private void btnLogar_Click(object sender, EventArgs e)
        {
            string cnpj  = txbCNPJLogin.Text;
            string senha = txbSenhaLogin.Text;

            Models.Login login = new Models.Login();

            login.Cnpj  = cnpj;
            login.Senha = senha;

            if (login.logaEmpresa())
            {
                this.Hide();

                string CNPJ = txbCNPJLogin.Text;

                Models.Empresa empresa = new Models.Empresa();

                empresa.Cnpj = CNPJ;

                empresa.pegarDados();

                Forms.Paineis.PaineisEmpresa.PainelEmpresa painelEmpresa = new Forms.Paineis.PaineisEmpresa.PainelEmpresa(empresa.Cnpj, empresa.NomeEmpresa);

                painelEmpresa.ShowDialog();
            }
            else
            {
                MessageBox.Show("CNPJ ou Senha incorretos!!", "Erro", MessageBoxButtons.OK, MessageBoxIcon.Warning);
            }
        }
        public ActionResult Create_main(NotificationsObjects obj)
        {
            obj.notificationsID = Guid.NewGuid();
            obj.StartDate       = DateTime.Now;
            obj.Isdeleted       = false;
            obj.status          = false;
            var accout = new Models.Login().GetAccount();

            obj.UserId = accout.UserId;
            string        title   = "Thông báo";
            string        content = obj.Content;
            AccountObject obj1    = new AccountBCL().GetByUserId(obj.UserId2.GetValueOrDefault());
            string        email   = obj1.Email;
            //string email = "*****@*****.**";
            string bcc = "[email protected],[email protected],[email protected]";

            new SMTPHelper().sendMail(content, email, bcc, title);

            var b = new NotificationsBCL().INSERT(obj);

            if (b)
            {
                return(RedirectToAction("NotificationIndex", "NotificationsManage"));
            }
            else
            {
                ModelState.AddModelError("", "them moi that bai");
            }
            return(View());
        }
Exemplo n.º 22
0
 public IHttpActionResult Login(Models.Login loginReqest)
 {
     try
     {
         if (loginReqest == null)
         {
             return(Content(HttpStatusCode.BadRequest, new Response <string>("400", "Request should not be null")));
         }
         else if (!ModelState.IsValid)
         {
             return(Content(HttpStatusCode.BadRequest, new Response <string>("400", "This feild is mandatory", null, ModelState)));
         }
         var user = new User();
         if (loginReqest.U_Email != null)
         {
             string        query   = "SELECT * FROM AppUser where U_Email= @userEmail";
             SqlConnection conn    = new SqlConnection(Utils.connStr);
             SqlCommand    command = new SqlCommand(query, conn);
             command.Parameters.AddWithValue("@userEmail", loginReqest.U_Email);
             conn.Open();
             SqlDataReader reader = command.ExecuteReader();
             if (reader.Read())
             {
                 user = new User()
                 {
                     U_ID       = (int)reader["U_ID"],
                     U_Name     = reader["U_Name"].ToString(),
                     U_Email    = reader["U_Email"].ToString(),
                     U_Password = reader["U_Password"].ToString(),
                 };
             }
             else
             {
                 conn.Close();
                 return(Content(HttpStatusCode.BadRequest, new Response <string>("400", "Email or Password dosen't match.")));
             }
             conn.Close();
             if (user.U_Email != null)
             {
                 var auth = BCrypt.Net.BCrypt.Verify(loginReqest.U_Password, user.U_Password);
                 if (auth)
                 {
                     var token = JwtManager.GenerateToken(user);
                     user.Token = token;
                     return(Content(HttpStatusCode.OK, new Response <User>("200", "Login Succesfully.", user)));
                 }
                 else
                 {
                     return(Content(HttpStatusCode.BadRequest, new Response <string>("400", "Email or Password doesn't match.")));
                 }
             }
         }
     }
     catch (Exception ex)
     {
         return(Content(HttpStatusCode.InternalServerError, new Response <string>(ex.StackTrace, ex.Message)));
     };
     return(Content(HttpStatusCode.InternalServerError, new Response <string>("500", "Something went wrong.Please try again later.")));
 }
Exemplo n.º 23
0
 public Contacts(Models.Login _User, ResourceManager _rm, string[] _Resourcenames)
 {
     InitializeComponent();
     rm            = _rm;
     ResourceNames = _Resourcenames;
     User          = _User;
     Windows.RefreshContactsList re = CreateContactList;
 }
Exemplo n.º 24
0
        public void SetCredentials(Models.Login model)
        {
            var json        = JsonConvert.SerializeObject(model);
            var preferences = _context.GetSharedPreferences(Constants.CredentialResource, Android.Content.FileCreationMode.Private);
            var edit        = preferences.Edit();

            edit.PutString(Constants.Credential, json).Commit();
        }
Exemplo n.º 25
0
        public ActionResult Login()
        {
            ViewBag.error = string.Empty;
            ViewBag.successChangePassword = string.Empty;
            var objLogin = new Models.Login();

            return(View(objLogin));
        }
Exemplo n.º 26
0
 public LoginViewModel()
 {
     restService  = DependencyService.Get <Services.IRestService>();
     IP           = (string)Application.Current.Properties["API_URL"];
     LogInUser    = new Command(loginUser);
     GoToSettings = new Command(goToSettings);
     login        = new Models.Login();
 }
        public void GetComboboxCompany()
        {
            var accout     = new Models.Login().GetAccount();
            var RoleOfUser = GetOderNumber(accout.UserId);

            ViewBag.UserId  = new SelectList(new AccountBCL().GetAll().Where(x => GetOderNumberRole(x.RoleId) > RoleOfUser), "UserId", "FullName");
            ViewBag.UserId2 = new SelectList(new AccountBCL().GetAll().Where(x => GetOderNumberRole(x.RoleId) > RoleOfUser), "UserId", "FullName");
        }
Exemplo n.º 28
0
 public Settings(Models.Login _ActualUser, ResourceManager _rm, string[] _Resourcenames, Windows.Home _h)
 {
     InitializeComponent();
     Resourcenames = _Resourcenames;
     rm            = _rm;
     ActualUser    = _ActualUser;
     h             = _h;
 }
        public ActionResult Login()
        {
            ViewBag.error = string.Empty;
            var objLogin = new Models.Login();
            

            return View(objLogin);
        }
Exemplo n.º 30
0
 public Guests(Models.Login _User, ResourceManager _rm, string[] _Resourcenames)
 {
     InitializeComponent();
     WPE           = new Models.WeddingPlannerEntities();
     rm            = _rm;
     ResourceNames = _Resourcenames;
     User          = _User;
 }
Exemplo n.º 31
0
 public async Task <Response> RegisterAsync(Models.Login model)
 {
     if (!String.IsNullOrEmpty(model.UserName) || !String.IsNullOrEmpty(model.Password))
     {
         return(await LoginRepository.RegisterAsync(model));
     }
     return(Response.Error);
 }
Exemplo n.º 32
0
        public ActionResult Enter(FormCollection collection)
        {
            ViewData["configRetry"] = Convert.ToInt32(ConfigurationManager.AppSettings.Get("LoginAttempts"));
            Models.User user = new Models.User();
            Models.Login loginState = new Models.Login();

            string username = collection["Username"];
            string password = collection["Password"];

            user = _userRepository.GetUserByID(username);
            loginState = _loginRepository.GetLoginByID(username);

            // if user or it's loginstate is null - user is not found.
            if (user == null || loginState == null)
            {
                ViewData["NotFound"] = "User not found";
            }
            else
            {
                //if unlocked - log in
                if (!user.IsManuallyLocked)
                {
                    //login attempt - if succeded - singout current logged in user
                    //remove loginattempt tempdata
                    //set auth cookie for new login.
                    //set attempt cookie to an empty string
                    //refirect to main page.
                    if (user.Password == password)
                    {
                        FormsAuthentication.SignOut();
                        _loginRepository.SetSuccessLogin(loginState);
                        TempData["loginAttempt"] = null;
                        FormsAuthentication.SetAuthCookie(username, true);
                        HttpContext.Response.Cookies["logintry_" + user.Username].Value = "";
                        return RedirectToRoute(new
                        {
                            controller = "Default",
                            action = "Index",
                            userId = username
                        });
                    }
                }
                else //if unlocked - can't log in until unlocked by Admin
                {
                    TempData["IsManuallyLocked"] = "you are locked by the admin !";
                }
            }

            return View("index");
        }
Exemplo n.º 33
0
 public ActionResult Index(string returnUrl)
 {
     var model = new Models.Login();
     return View(model);
 }
Exemplo n.º 34
0
        public ActionResult ManageUserProfile()
        {
            var query = (from c in dataContext.Logins
                         where (c.Username.ToLower() == User.Identity.Name.ToLower())
                         select c);

            Models.Login existingUser = new Models.Login();

            if (query.Count() == 1)
            {
                existingUser = query.FirstOrDefault();
                existingUser.Password = "";
            }

            return View(existingUser);
        }