本文整理汇总了C#中LoginModel类的典型用法代码示例。如果您正苦于以下问题:C# LoginModel类的具体用法?C# LoginModel怎么用?C# LoginModel使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
LoginModel类属于命名空间,在下文中一共展示了LoginModel类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C#代码示例。
示例1: Login
public async Task<ActionResult> Login(LoginModel model)
{
if (!ModelState.IsValid)
{
return View(model);
}
var blogContext = new BlogContext();
var user = await blogContext.Users.Find(x => x.Email == model.Email).SingleOrDefaultAsync();
if (user == null)
{
ModelState.AddModelError("Email", "Email address has not been registered.");
return View(model);
}
var identity = new ClaimsIdentity(new[] {
new Claim(ClaimTypes.Name, user.Name),
new Claim(ClaimTypes.Email, user.Email)
}, "ApplicationCookie");
var context = Request.GetOwinContext();
var authManager = context.Authentication;
authManager.SignIn(identity);
return Redirect(GetRedirectUrl(model.ReturnUrl));
}
开发者ID:ibezuglyi,项目名称:mongo.blog,代码行数:27,代码来源:AccountController.cs
示例2: Index
public ActionResult Index(LoginModel model)
{
var displaydeps = db.Departments.Where(s => s.DepartmentCode != null).ToList();
IEnumerable<SelectListItem> selectList = from s in displaydeps
select new SelectListItem
{
Text = s.DepartmentCode + " - " + s.Name,
Value = s.DepartmentCode
};
ViewBag.DisplayDepartments = new SelectList(selectList, "Text" , "Value");
if (ModelState.IsValid)
{
if (DataAccessLayer.UserIsValid(model.DisplayDepartments, model.Password))
{
string selectedDepartment = model.DisplayDepartments;
Session["department"] = selectedDepartment;
FormsAuthentication.SetAuthCookie(model.DisplayDepartments, false); //set to false: cookie is destroyed when browser is closed - user will have to login in again if browser is closed
return RedirectToAction("index", "AddRequest", selectedDepartment); //page is redirected to the page 'index' which has the controller 'home'
}
{
ModelState.AddModelError("", "Invalid password");
}
}
return View();
}
开发者ID:TeamProjectsDeliverable3,项目名称:TP3,代码行数:31,代码来源:loginController.cs
示例3: Login
public ActionResult Login(LoginModel model)
{
using (var db = new ReqcyclerEntities())
{
var tmpUser = (db.Usuario
.Where(u => u.email == model.LoginMail)
.FirstOrDefault()) as Usuario;
if (tmpUser != null)
{
var numProjetos = (from pu in db.ProjetoUsuario
join p in db.Projeto on pu.projetoId equals p.id
where pu.usuarioId == tmpUser.id
select pu).ToList().Count();
Session["UsuarioLogadoID"] = tmpUser.id;
Session["UsuarioLogado"] = ((Usuario)tmpUser).nome;
Session["NumProjetos"] = (Int32)numProjetos;
return RedirectToAction("Index", "Home");
}
else
{
return RedirectToAction("Index", "Login");
}
}
}
开发者ID:GuilhermeCalegari,项目名称:elicitacao-maturamento-requisitos,代码行数:26,代码来源:LoginController.cs
示例4: Login
public ViewResult Login()
{
LoginModel model = new LoginModel();
model.Realm = AuthenticationUtility.GetApplicationUri(HttpContext.Request);
model.Namespace = CloudConfigurationManager.GetSetting("AcsNamespace");
return View(model);
}
开发者ID:modulexcite,项目名称:StudentSuccessDashboard,代码行数:7,代码来源:AccountController.cs
示例5: Login
public ActionResult Login(LoginModel login)
{
if (ModelState.IsValid)
{
var user = new AuthRepository().Login(login.Username, login.Password);
if (user != null)
{
// Create ticket
var ticket = new FormsAuthenticationTicket(1, login.Username,
DateTime.Now, DateTime.Now.AddMinutes(2880),
false,
Enum.GetName(typeof(Role), user.Position),
FormsAuthentication.FormsCookiePath);
// Encode ticket
string hash = FormsAuthentication.Encrypt(ticket);
var cookie = new HttpCookie(FormsAuthentication.FormsCookieName, hash);
if (ticket.IsPersistent)
{
cookie.Expires = ticket.Expiration;
}
//Save ticket in coockie
Response.Cookies.Add(cookie);
if (user.Position == Role.User)
return RedirectToAction("UserPage", "Profile");
if (user.Position == Role.Restaurateur)
return RedirectToAction("RestaurateurPage", "Profile");
}
}
return View(login);
}
开发者ID:pasha369,项目名称:RestaurantManagementSystem,代码行数:34,代码来源:AccountController.cs
示例6: Login
/// <summary>
/// 用户登录
/// </summary>
/// <param name="model">登录模型信息</param>
/// <returns>业务操作结果</returns>
public OperationResult Login(LoginModel model)
{
Validator.ValidateObject(model, new ValidationContext(model));
LoginInfo2 loginInfo = new LoginInfo2
{
Access = model.Account,
Password = model.Password,
};
OperationResult result = base.Login(loginInfo);
if (result.ResultType == OperationResultType.Success)
{
User user = (User)result.AppendData;
List<UserGroup> usergroups =user.UserGroups.ToList();
List<Res> reses = new List<Res>();
List<Mdl> mdls = new List<Mdl>();
foreach (var a in usergroups)
{
reses.AddRange(a.Ress);
mdls.AddRange(a.Mdls);
}
if (reses.SingleOrDefault(r=>r.RESCODE==model.ResCode)==null)
{
result.ResultType = OperationResultType.Error;
result.Message = "用户没有该资源的权限";
}
result.AppendData = mdls;
}
return result;
}
开发者ID:TGHGH,项目名称:MesSolution,代码行数:35,代码来源:UserFormService.cs
示例7: LogOn
public ActionResult LogOn(LoginModel employee)
{
if (ModelState.IsValid)
{
Employee user = _LoginService.Login(new Employee { EmployeeName = employee.UserName, Password = employee.Password });
if (user != null)
{
if (!_LoginService.IpAccess_Check(user))
{
ViewBag.LoginFailed = "ip验证错误";
ViewBag.isload = false;
return View("Index");
}
user.Sid = AppData.CreateRandomCode(24);//登录成功,写入24为随机字符,用于比对是否重读登录
DateTime loginDate=DateTime.Now;
user.LoginDate = loginDate.Date;
user.LoginTime = loginDate.Subtract(user.LoginDate.Value);
_LoginService.Update(user);
_LoginService.Commit();
FormsAuthentication.SetAuthCookie(user.Rank + "," + user.EmployeeName + "," + user.Sid, true);
return RedirectToAction("Index", "SPBG", new { area = "SPBG" });
}
ViewBag.LoginFailed = "帳號或密碼錯誤";
}
ViewBag.isload = false;
return View("Index");
}
开发者ID:chanhan,项目名称:subao_bg,代码行数:27,代码来源:LoginController.cs
示例8: Login
public ActionResult Login(LoginModel model)
{
if (ModelState.IsValid)
{
Account account = accountRepository.HaalAccountOp(model.Naam, model.Wachtwoord);
if (account != null)
{
FormsAuthentication.SetAuthCookie(account.Wachtwoord, false);
//account onthouden
Session["loggedIn_account"] = account;
//
return RedirectToAction("index", "Contact");
}
else
{
//
}
}
else
{
ModelState.AddModelError("login_error", "naam of wachtwoord incorrect");
}
return View(model);
}
开发者ID:Ctiel,项目名称:WhatsUp,代码行数:28,代码来源:AccountController.cs
示例9: GetUser
public UserModel GetUser(LoginModel model)
{
User user = null;
if (model.provider == Provider.Twitter)
{
user = repository.AsQueryable<User>().FirstOrDefault(x => x.TwitterSecret == model.Secret && x.TwitterToken == model.Token) ?? new User();
user.TwitterToken = model.Token;
user.TwitterSecret = model.Secret;
user.TwitterEnabled = true;
repository.Save(user);
}
else if (model.provider == Provider.Facebook)
{
user = repository.AsQueryable<User>().FirstOrDefault(x => x.FacebookId == model.ExternalId) ?? new User();
user.FacebookId = model.ExternalId;
user.FacebookToken = model.Token;
user.FacebookEnabled = true;
repository.Save(user);
}
repository.Commit();
var response = new UserModel()
{
UserId = user.Id,
IsFacebookEnabled = user.FacebookEnabled,
IsTwitterEnabled = user.TwitterEnabled
};
return response;
}
开发者ID:hafnis,项目名称:Sociopath,代码行数:31,代码来源:UserService.cs
示例10: Login
public ActionResult Login(LoginModel model, string returnUrl)
{
if (ModelState.IsValid)
{
if (Membership.ValidateUser(model.UserName, model.Password))
{
FormsAuthentication.SetAuthCookie(model.UserName, model.RememberMe);
if (Url.IsLocalUrl(returnUrl))
{
return Redirect(returnUrl);
}
else
{
return RedirectToAction("Index", "Home");
}
}
else
{
ModelState.AddModelError("", "The user name or password provided is incorrect.");
}
}
// If we got this far, something failed, redisplay form
return View(model);
}
开发者ID:jonquick,项目名称:aspectCloud,代码行数:25,代码来源:AccountController.cs
示例11: ViewDidLoad
public override void ViewDidLoad()
{
base.ViewDidLoad ();
this.ForgotPassword.TouchUpInside += (object sender, EventArgs e) => {
var board = UIStoryboard.FromName ("MainStoryboard", null);
var password = (ForgotPasswordController)board.InstantiateViewController ("forgotpassword");
this.NavigationController.PushViewController(password, true);
};
this.Login.TouchUpInside += (object sender, EventArgs e) => {
//((UIWindow)UIApplication.SharedApplication.Delegate.Window).RootViewController =
// new MainTabController();
var request = new RestRequest();
var model = new LoginModel { Email = this.Email.Text, Password = this.Password.Text, RememberMe = true };
request.Send(RequestConfig.Login, "POST", model);
request.RequestFinished += (object send, RequestEndedArgs ev) => {
var jsonId = (int)JsonConvert.DeserializeObject (ev.Result, typeof(int));
InvokeOnMainThread (delegate {
AppDelegate.SaveProfileId(jsonId);
var tabbar = new MainTabController();
UIApplication.SharedApplication.Delegate.Window.RootViewController = tabbar;
});
};
};
}
开发者ID:jgrozdanov,项目名称:mono-sport,代码行数:26,代码来源:LoginController.cs
示例12: GetUserRedirect
internal static string GetUserRedirect(LoginModel model)
{
WebMatrix.WebData.SimpleRoleProvider roleProvider = new WebMatrix.WebData.SimpleRoleProvider();
string redirect_url = "";
string[] roles = roleProvider.GetRolesForUser(model.UserName);
foreach (string role in roles)
{
switch (role.ToLower())
{
case "administrator":
redirect_url = "Admin/Dashboard";
break;
case "customer" :
redirect_url = "Site/Dashboard";
break;
default :
redirect_url = "Site/Dashboard";
break;
}
}
return redirect_url;
}
开发者ID:rexwhitten,项目名称:reportspace,代码行数:25,代码来源:SecurityModel.cs
示例13: Login
public async Task<ActionResult> Login(LoginModel model)
{
if (!ModelState.IsValid)
{
return View(model);
}
var user = await _applicationService.GetCandidateByEmailAsync(model.Email);
if (user == null)
{
AddWrongEmailPasswordError();
return View(model);
}
var hashPassword = _applicationService.GenerateHashPassword(model.Password, user);
if (hashPassword == user.Password)
{
var identity = _authenticationService.CreateCandidateIdentity(user);
_authenticationService.SignIn(identity, Request);
if (user.HasSkills())
{
return Redirect(GetRedirectUrl(model.ReturnUrl));
}
return RedirectToAction("Index", "CandidateProfile");
}
AddWrongEmailPasswordError();
return View(model);
}
开发者ID:ibezuglyi,项目名称:Summer2015,代码行数:27,代码来源:CandidateController.cs
示例14: Login
public OperationResult Login(LoginModel model)
{
var operationResult = new OperationResult(OperationResultType.Error);
Validator.ValidateObject(model, new ValidationContext(model));
User user = UserFormService.Users().SingleOrDefault(m => m.usercode == model.Account);
if (user == null)
{
operationResult.Message = Properties.Resources.FrmLogin_Login_UserNotExist;
return operationResult;
}
if (user.userpwd != model.Password)
{
operationResult.Message = Properties.Resources.FrmLogin_Login_PasswordError;
return operationResult;
}
var usergroups = user.UserGroups.ToList();
var reses = new List<Res>();
var mdls = new List<Mdl>();
foreach (var a in usergroups)
{
reses.AddRange(a.Ress);
mdls.AddRange(a.Mdls);
}
if (reses.SingleOrDefault(r => r.RESCODE == model.ResCode) == null)
{
operationResult.Message = Properties.Resources.FrmLogin_Login_UserNotRes;
return operationResult;
}
operationResult.ResultType=OperationResultType.Success;
operationResult.AppendData = mdls;
operationResult.Message = Properties.Resources.FrmLogin_Login_LoginSuccess;
return operationResult;
}
开发者ID:TGHGH,项目名称:MesSolution,代码行数:34,代码来源:FrmLoginService.cs
示例15: Login
public ActionResult Login(LoginModel model, string returnUrl)
{
if (ModelState.IsValid)
{
var result = this._userService.Authenticate(model.UserName, model.Password);
if (ModelState.Process(result))
{
var user = result.Entity;
_authenticationService.SignIn(user, model.RememberMe);
if (_userService.IsPasswordExpired(model.UserName))
{
return RedirectToAction("ChangePassword", "Account");
}
new MembershipEvent(MembershipEventCode.UserLogin, user).Raise();
if (Url.IsLocalUrl(model.ReturnUrl))
{
return Redirect(model.ReturnUrl);
}
return RedirectToAction("Index", "Home");
}
ModelState.AddModelError("", "Invalid Username or Password");
}
return View(model);
}
开发者ID:shizik,项目名称:ScaffR-Generated,代码行数:29,代码来源:AccountController.Login.cs
示例16: LoginState
public LoginState()
: base()
{
m_UserInterface = ServiceRegistry.GetService<UserInterfaceService>();
m_Login = ServiceRegistry.GetService<LoginModel>();
m_Input = ServiceRegistry.GetService<InputManager>();
}
开发者ID:InjectionDev,项目名称:UltimaXNA,代码行数:7,代码来源:LoginState.cs
示例17: Index
public ViewResult Index(string Name, string Email, string Password)
{
try
{
UserRepository userRep = new UserRepository();
Expression<Func<t_user, bool>> filter =
x => (x.mail == Email && Email != null);
List<t_user> users = userRep.Get(filter).ToList();
LoginModel model = new LoginModel();
if (users.Count > 0)
{
return View(model);
}
else
{
t_user newUser = new t_user();
newUser.name = Name;
newUser.mail = Email;
newUser.password = Password;
newUser.roleID = 2;
userRep.Save(newUser);
model.Name = Name;
model.Email = Email;
model.Password = Password;
}
return View(model);
}
catch (Exception)
{
return null;
}
}
开发者ID:lxsndr33,项目名称:Auction,代码行数:35,代码来源:UserController.cs
示例18: Login
public async Task<ActionResult> Login(LoginModel model)
{
if (!ModelState.IsValid)
{
return View();
}
var authProxy = new AuthenticationProxy(WebConfigurationManager.AppSettings["WebApiUrl"], "/api/oauth");
var token = await authProxy.Login(model.UserName, model.Password);
if (token == null)
{
ModelState.AddModelError("password", "Wachtwoord of gebruikersnaam is onjuist");
return View();
}
var tokenCookie = new HttpCookie("token", token.Value)
{
Expires = DateTime.Now.AddMinutes(token.ExpiresIn),
HttpOnly = false
};
var roleCookie = new HttpCookie("role", token.Role)
{
Expires = DateTime.Now.AddMinutes(token.ExpiresIn),
HttpOnly = true
};
Response.Cookies.Add(tokenCookie);
Response.Cookies.Add(roleCookie);
return RedirectToAction("Index", "Dashboard");
}
开发者ID:AndreasFurster,项目名称:kiwi,代码行数:33,代码来源:AccountController.cs
示例19: Login
public async Task<ActionResult> Login(LoginModel model, string returnUrl)
{
if (ModelState.IsValid)
{
ApplicationUser user = await UserManager.FindAsync(model.Email, model.Password);
if (user == null)
{
ModelState.AddModelError("", "Неверный логин или пароль.");
}
else
{
ClaimsIdentity claim = await UserManager.CreateIdentityAsync(user,
DefaultAuthenticationTypes.ApplicationCookie);
AuthenticationManager.SignOut();
AuthenticationManager.SignIn(new AuthenticationProperties
{
IsPersistent = true
}, claim);
if (String.IsNullOrEmpty(returnUrl))
return RedirectToAction("Index", "Account");
return Redirect(returnUrl);
}
}
ViewBag.returnUrl = returnUrl;
return View(model);
}
开发者ID:Winbringer,项目名称:CSharpBlog,代码行数:26,代码来源:AccountController.cs
示例20: GetUser
public TwitterUser GetUser(LoginModel model)
{
var twitterService = new TweetSharp.TwitterService(ConsumerKey, ConsumerSecret);
twitterService.AuthenticateWith(model.Token, model.Secret);
TwitterUser user = twitterService.VerifyCredentials(new VerifyCredentialsOptions() { IncludeEntities = false, SkipStatus = false });
return user;
}
开发者ID:hafnis,项目名称:Sociopath,代码行数:7,代码来源:TwitterService.cs
注:本文中的LoginModel类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论