public async Task <IActionResult> Authorize(AuthorizeViewModel model) { var capp = await APIService.AppInfoAsync(model.AppId); if (ModelState.IsValid) { var result = await _signInManager.PasswordSignInAsync(model.Email, model.Password, isPersistent : model.RememberMe, lockoutOnFailure : true); if (result.Succeeded) { return(await FinishAuth(model, capp.ForceConfirmation)); } else if (result.RequiresTwoFactor) { throw new NotImplementedException(); } else if (result.IsLockedOut) { throw new NotImplementedException(); } else { ModelState.AddModelError(string.Empty, "Invalid login attempt."); } } model.Recover(capp.AppName, capp.AppImageUrl); return(View(model)); }
public async Task <IActionResult> AuthorizeConfirm(AuthorizeConfirmAddressModel model) { var cuser = await GetCurrentUserAsync(); if (ModelState.IsValid && cuser != null) { var capp = await APIService.AppInfoAsync(model.AppId); var viewModel = new AuthorizeConfirmViewModel { AppName = capp.AppName, UserNickName = cuser.NickName, AppId = model.AppId, ToRedirect = model.ToRedirect, State = model.State, Scope = model.Scope, ResponseType = model.ResponseType, UserIcon = cuser.HeadImgUrl, }; return(View(viewModel)); } return(View()); }
//http://localhost:62631/oauth/authorize?appid=29bf5250a6d93d47b6164ac2821d5009&redirect_uri=http%3A%2F%2Flocalhost%3A55771%2FAuth%2FAuthResult&response_type=code&scope=snsapi_base&state=http%3A%2F%2Flocalhost%3A55771%2FAuth%2FGoAuth#aiursoft_redirect public async Task <IActionResult> Authorize(AuthorizeAddressModel model) { var capp = await APIService.AppInfoAsync(model.appid); var url = new Uri(model.redirect_uri); if (url.Host != capp.AppDomain && capp.DebugMode == false) { ModelState.AddModelError(string.Empty, "Redirect uri did not work in the valid domain!"); return(View()); } var cuser = await GetCurrentUserAsync(); if (cuser != null && capp.ForceInputPassword == false && model.ForceSignInLocally == false) { return(await FinishAuth(model.Convert(cuser.Email), capp.ForceConfirmation)); } if (ModelState.IsValid) { var viewModel = new AuthorizeViewModel(model.redirect_uri, model.state, model.appid, model.scope, model.response_type, capp.AppName, capp.AppImageUrl); return(View(viewModel)); } return(View()); }