public ActionResult <IEnumerable <string> > GetBookings(LoginPost loginPost, string eventUid) { var eventId = new VeranstaltungenModel().GetEvent(eventUid); if (eventId == null) { return(NotFound()); } var calendarId = new VeranstaltungenModel().GetCalendarId(eventUid); if (!auth.CheckIfCalendarPermissions(loginPost, calendarId)) { return(Unauthorized()); } var query = Request.QueryString.ToUriComponent(); query = System.Web.HttpUtility.UrlDecode(query); var result = model.GetBookings(eventUid, query); if (result != null) { return(Content(result, "application/json")); } else { return(NotFound()); } }
public ActionResult <IEnumerable <string> > SubmitCode(LoginPost loginPost, string code) { if (!auth.CheckIfDebugPermissions(loginPost)) { return(Unauthorized()); } var id = model.GetVerificationCodeId(code); if (id == -1) { return(NotFound()); } var result = model.DeleteVerificationCode(id); if (result) { return(Ok()); } else { return(BadRequest()); } }
/// <summary> /// 暴走账号登录 /// </summary> /// <param name="userName"></param> /// <param name="password"></param> /// <returns></returns> public async Task <User> LoginAsync(string userName, string password) { //先清除Authorization信息 HttpBaseService.RemoveHeader("Authorization"); var result = await BaoZouOAuthAsync(userName, password); if (result != null && string.IsNullOrEmpty(result.Error)) { LoginPost loginPost = new LoginPost() { AccessToken = result.AccessToken, Source = "baozou", User = result.UserId }; User user = await GetUserInfo(loginPost); if (user != null) { HttpBaseService.SetHeader("Authorization", "Bearer " + user.AccessToken); } return(user); } return(null); }
public async Task <LoginResponse> socialLogin(string userUid) { const string deviceBrowserType = "Mobile"; const string deviceIpAddress = "0.0.0.0"; LoginPost loginPostContent = new LoginPost() { // object that contains ip address and browser type; will be converted into a json object ipAddress = deviceIpAddress.ToString(), browserType = deviceBrowserType }; string loginPostContentJson = JsonConvert.SerializeObject(loginPostContent); // make orderContent into json var httpContent = new StringContent(loginPostContentJson, Encoding.UTF8, "application/json"); // encode orderContentJson into format to send to database var response = await client.PostAsync(socialLoginUrl + userUid, httpContent); // try to post to database if (response.StatusCode == HttpStatusCode.OK) { var responseContent = await response.Content.ReadAsStringAsync(); var loginResponse = JsonConvert.DeserializeObject <LoginResponse>(responseContent); return(loginResponse); } return(null); }
public ActionResult <IEnumerable <string> > DeleteParticipant(LoginPost loginPost, string eventUid, long participationId) { var v = new VeranstaltungenModel(); var calId = v.GetCalendarId(eventUid); var eventId = new BuchungenModel().GetEventId(eventUid); if (calId == -1) { return(NotFound()); } if (!auth.CheckIfCalendarPermissions(loginPost, calId)) { return(Unauthorized()); } if (model.DeleteParticipant(new Dictionary <string, string> { { "veranstaltung", eventId }, { "nutzer", participationId.ToString() } })) { return(Ok()); } else { return(NotFound()); } }
public IEnumerator PostLoginEstudiante(string url, LoginPost postestudiante) { var jsonData = JsonUtility.ToJson(postestudiante); using (UnityWebRequest www = UnityWebRequest.Post(url, jsonData)) { www.SetRequestHeader("content-type", "application/json"); www.uploadHandler.contentType = "application/json"; www.uploadHandler = new UploadHandlerRaw(System.Text.Encoding.UTF8.GetBytes(jsonData)); yield return(www.SendWebRequest()); if (www.isNetworkError) { Debug.Log(www.error); } else { if (www.isDone) { // handle the result var result = System.Text.Encoding.UTF8.GetString(www.downloadHandler.data); Debug.Log(result); var msg = JsonUtility.FromJson <ResLogin>(result); Debug.Log(msg.message); Debug.Log(msg.user.password); } else { //handle the problem Debug.Log("Error! data couldn't get."); } } } }
public ActionResult <IEnumerable <string> > DeleteCalendarOrganizer(LoginPost loginPost, long calendarId, long organizerId) { if (!auth.CheckIfCalendarPermissions(loginPost, calendarId)) { return(Unauthorized()); } var result = model.GetCalendarOrganizers(calendarId); if (result != null) { if (model.DeleteCalendarOrganizer(calendarId, organizerId)) { return(Ok()); } else { return(Conflict()); } } else { return(NotFound()); } }
public ActionResult LoginIn(LoginPost model) { if (User.Identity.IsAuthenticated) { FormsAuthentication.SignOut(); } if (ModelState.IsValid) { string srt = LogTo(model); if (srt == "") { FormsAuthentication.SetAuthCookie(model.user, true); FormsAuthenticationTicket ticket = new FormsAuthenticationTicket(1, model.user, DateTime.Now, DateTime.Now.AddMinutes(60), false, ""); //数据加密 string enyTicket = FormsAuthentication.Encrypt(ticket); HttpCookie cookie = new HttpCookie(FormsAuthentication.FormsCookieName, enyTicket); System.Web.HttpContext.Current.Response.Cookies.Add(cookie); return(Redirect("/Home/Index")); } else { ViewBag.Error = srt; } } return(RedirectToAction("Login", model)); }
// logs the user into the app // returns a LoginResponse if successful and null if unsuccessful public async Task <LoginResponse> login(string userEmail, string userPassword) { try { LoginPost loginPostContent = new LoginPost() { // object that contains ip address and browser type; will be converted into a json object Email = userEmail, Password = userPassword }; string loginPostContentJson = JsonConvert.SerializeObject(loginPostContent); // make orderContent into json var httpContent = new StringContent(loginPostContentJson, Encoding.UTF8, "application/json"); // encode orderContentJson into format to send to database var response = await client.PostAsync(loginURL, httpContent); // try to post to database if (response.Content != null) { // post was successful var responseContent = await response.Content.ReadAsStringAsync(); var loginResponse = JsonConvert.DeserializeObject <LoginResponse>(responseContent); return(loginResponse); } } catch (Exception e) { Console.WriteLine("Error in login.xaml " + e); } return(null); }
public HttpResponseMessage Login(LoginPost postVal) { HttpResponseMessage Resp = Request.CreateResponse(); try { SSRSProAuthData data = null; if (Auth != null) { data = Auth.Login(postVal.UserName, postVal.Password); } if (data != null || Auth == null) { Util.SetCookie(this.Request, Resp, data); Resp.Content = new StreamContent((new MemoryStream(Encoding.UTF8.GetBytes("{\"status\":\"success\"}")))); return(Resp); } else { Resp.Content = new StreamContent((new MemoryStream(Encoding.UTF8.GetBytes("{\"status\":\"failed\"}")))); return(Resp); } } catch (Exception e) { Resp.Content = new StreamContent((new MemoryStream(Encoding.UTF8.GetBytes(JsonConvert.SerializeObject(e))))); return(Resp); } }
public ActionResult <IEnumerable <string> > ProcessBookings(LoginPost loginPost, string eventUid, long bookingId) { if (!auth.CheckIfDebugPermissions(loginPost)) { return(Unauthorized()); } if (new VeranstaltungenModel().GetCalendarId(eventUid) == -1) { return(NotFound()); } if (model.GetBooking(bookingId) == null) { return(NotFound()); } if (model.GetEventIdOfBooking(bookingId) != model.GetEventId(eventUid)) { return(BadRequest()); } if (model.ProcessBooking(bookingId)) { return(Ok()); } else { return(Conflict()); } }
public async Task <SsoResponse> Login([FromBody] LoginPost data) { try { var token = new PlexToken(data.Token); var(accessTier, loggedIn) = GetAccessTier(); if (!loggedIn) { accessTier = await _plexClient.GetAccessTier(serverIdentifier, token); } if (accessTier == AccessTier.Failure) { var loginFailureResponse = _authValidator.ValidateAuthenticationStatus(AccessTier.NoAccess, false, GetServiceName(), GetServiceUri(), string.Empty); Response.StatusCode = loginFailureResponse.Status; return(loginFailureResponse); } var user = await _plexClient.GetUserInfo(token); var claims = new List <Claim> { new Claim(Constants.AccessTierClaim, accessTier.ToString()), new Claim(Constants.AccessTokenClaim, token.Value), new Claim(Constants.ServerIdentifierClaim, serverIdentifier.Value), new Claim(Constants.UsernameClaim, user.Username), new Claim(Constants.EmailClaim, user.Email), new Claim(Constants.ThumbnailClaim, user.Thumbnail) }; var identity = new ClaimsIdentity( claims, CookieAuthenticationDefaults.AuthenticationScheme ); var authProperties = new AuthenticationProperties { AllowRefresh = true, IsPersistent = true }; await HttpContext.SignInAsync( CookieAuthenticationDefaults.AuthenticationScheme, new ClaimsPrincipal(identity), authProperties ); var response = _authValidator.ValidateAuthenticationStatus(accessTier, true, GetServiceName(), GetServiceUri(), user.Username); Response.StatusCode = response.Status; return(response); } catch (Exception e) { _logger.LogError("Failed to log user in", e); var unhandledErrorResponse = _authValidator.ValidateAuthenticationStatus(AccessTier.NoAccess, false, GetServiceName(), GetServiceUri(), string.Empty, true); Response.StatusCode = unhandledErrorResponse.Status; return(unhandledErrorResponse); } }
public ActionResult Login(LoginPost model) { if (User.Identity.IsAuthenticated) { FormsAuthentication.SignOut(); } return(View()); }
public ActionResult <IEnumerable <string> > CleanUpBookingData(LoginPost loginPost) { if (!auth.CheckIfDebugPermissions(loginPost)) { return(Unauthorized()); } model.WipeUnnecessaryData(); return(NoContent()); }
public ActionResult <IEnumerable <string> > CleanUpParticipantData(LoginPost loginPost) { if (!auth.CheckIfDebugPermissions(loginPost)) { return(BadRequest()); } model.WipeUnnecessaryData(); return(NoContent()); }
public ActionResult <IEnumerable <string> > GetAllParticipants(LoginPost loginPost) { if (!auth.CheckIfDebugPermissions(loginPost)) { return(Unauthorized()); } return(Content(model.GetParticipants(), "application/json")); }
public ActionResult <IEnumerable <string> > SendCodeEmail(LoginPost loginPost, string code) { if (!auth.CheckIfDebugPermissions(loginPost)) { return(Unauthorized()); } return(BadRequest()); }
public async Task <SsoResponse> Login([FromBody] LoginPost data) { try { Identity.AccessToken = new AccessToken(data.Token); Identity.ServerIdentifier = _serverIdentifier; if (!Identity.IsAuthenticated) { Identity.AccessTier = await _plexClient.GetAccessTier(_serverIdentifier, Identity.AccessToken); } if (Identity.AccessTier == AccessTier.Failure) { Identity.AccessTier = AccessTier.NoAccess; Identity.IsAuthenticated = false; return(GetErrorResponse()); } var user = await _plexClient.GetUserInfo(Identity.AccessToken); Identity.Email = user.Email; Identity.Username = user.Username; Identity.Thumbnail = user.Thumbnail; Identity.IsAuthenticated = true; var identity = new ClaimsIdentity( Identity.AsClaims(), CookieAuthenticationDefaults.AuthenticationScheme ); var authProperties = new AuthenticationProperties { AllowRefresh = true, IsPersistent = true }; await HttpContext.SignInAsync( CookieAuthenticationDefaults.AuthenticationScheme, new ClaimsPrincipal(identity), authProperties ); var response = _authValidator.ValidateAuthenticationStatus(Identity, ServiceName, ServiceUri); Response.StatusCode = response.Status; return(response); } catch (Exception e) { _logger.LogError("Failed to log user in", e); Identity.AccessTier = AccessTier.NoAccess; Identity.IsAuthenticated = false; return(GetErrorResponse()); } }
public void loginmetod() { LoginPost accesoestudiante = new LoginPost() { usuario = user.text, password = password.text }; StartCoroutine(PostLoginEstudiante(postloginestudiante, accesoestudiante)); }
public ActionResult <IEnumerable <string> > WipeUnnecessaryCodes(LoginPost loginPost) { if (!auth.CheckIfDebugPermissions(loginPost)) { return(Unauthorized()); } model.WipeUnnecessaryData(); return(Ok()); }
public ActionResult <IEnumerable <string> > SaveData(LoginPost loginPost) { if (!auth.CheckIfDebugPermissions(loginPost)) { return(Unauthorized()); } model.SaveData(); return(Ok()); }
public async Task <bool> Login([FromBody] LoginPost model) { if (ModelState.IsValid) { var result = await _signInManager.PasswordSignInAsync(model.Email, model.Password, model.Remember, false); return(result.Succeeded); } return(false); }
public ActionResult <IEnumerable <string> > GetAllCodes(LoginPost loginPost) { if (!auth.CheckIfDebugPermissions(loginPost)) { return(Unauthorized()); } var result = model.GetAllCodes(); return(Content(result, "application/json")); }
static void Main(string[] args) { var token = ""; var HttpClient = new HttpClient(); var resp = new LoginPost(new LoginDto()) .Dispatch(HttpClient).GetAwaiter().GetResult(); token = resp.Token; Console.WriteLine($"Мама я получил ебучий токен сука: {token}"); }
public ActionResult <IEnumerable <string> > GetLoggedInOrganizer(LoginPost loginPost) { var result = auth.GetLoggedInOrganizerData(loginPost); if (result == null) { return(Unauthorized()); } else { return(Content(result, "application/json")); } }
public ActionResult Login(LoginPost lgPost) { LoginServices loginServices = new LoginServices(); if (loginServices.CheckLogin(lgPost.email, Encode.CreateMD5(lgPost.password), lgPost.rememberMe) == true) { return(Json(new { _mess = 1 })); } else { return(Json(new { _mess = 0 })); } }
public ActionResult <IEnumerable <string> > GetAllOrganizers(LoginPost loginPost) { if (!auth.CheckIfOrganizerPermissions(loginPost)) { return(Unauthorized()); } var query = Request.QueryString.ToUriComponent(); query = System.Web.HttpUtility.UrlDecode(query); var result = model.GetOrganizers(query); return(Content(result, "application/json")); }
public IActionResult ProcessLogin([FromBody] LoginPost userInfo) { var userData = GetUserFromDB(userInfo.Username); if (userData == null || !BCrypt.Net.BCrypt.Verify(userInfo.Password, userData.Hash)) { return(BadRequest(new { error = "Incorrect username or password" })); } // Success var jwt = new JWT(_context, _config, userInfo.Username).GetToken(); return(Ok(new { jwt })); }
public ActionResult <IEnumerable <string> > GetOrganizer(LoginPost loginPost, long id) { if (!auth.CheckIfOrganizerPermissions(loginPost)) { return(Unauthorized()); } var result = model.GetOrganizer(id); if (result == null) { return(NotFound()); } return(Content(result, "application/json")); }
public ActionResult <IEnumerable <string> > ProcessBookings(LoginPost loginPost, string eventUid) { if (!auth.CheckIfDebugPermissions(loginPost)) { return(Unauthorized()); } if (new VeranstaltungenModel().GetCalendarId(eventUid) == -1) { return(NotFound()); } model.ProcessBookings(eventUid); return(Ok()); }
/// <summary> /// Get Method for logging the user in. /// </summary> /// <returns></returns> public HttpResponseMessage Post(LoginPost login) { //verify the token passed from the app is valid. Just an extra security measure tp make sure they're hitting from the app. var isAuthed = MobileAppAPIHelper.ValidateAppToken(Request); //if this check fails, return Unauthorized if (!isAuthed) return Request.CreateResponse(HttpStatusCode.Unauthorized); try { RestClient restClient = new RestClient(ApiUrls.BaseUrl); var request = new RestRequest(string.Format(ApiUrls.LoginPostUrl), Method.POST); request.AddJsonBody(login); var result = restClient.Execute(request); if (result.StatusCode == HttpStatusCode.NoContent && result.ResponseStatus == ResponseStatus.Completed) { var obj = new LoginReturnObject(); obj.Cookie = result.Cookies[0].Name + "=" + result.Cookies[0].Value; var rc = new RockContext(); var u = new UserLoginService(rc).GetByUserName(login.Username); if (u == null) return Request.CreateResponse(HttpStatusCode.NotFound); obj.Username = u.UserName; obj.EncodedUrl = u.UrlEncodedKey; return Request.CreateResponse(HttpStatusCode.OK, obj); } else { return Request.CreateResponse(result.StatusCode, result.StatusDescription); } } catch (Exception ex) { //todo: log the error somewhere. return Request.CreateResponse(HttpStatusCode.InternalServerError); } }