Exemple #1
0
        public async Task <IActionResult> OnPostLogIn()
        {
            HttpRequests r = new HttpRequests();
            LogIn        x = new LogIn();

            if (Username != "" & Password != "")
            {
                object u = new { username = Username, password = Password };
                try
                {
                    x = await r.LoginUser(u);
                }
                catch (Exception)
                {
                    x = new LogIn()
                    {
                        userId = 0, Token = ""
                    };
                }
            }
            if (x.Token != "" && x.userId != 0)
            {
                User us = await r.GetUserAsync(x.Token);

                BaseController.SetUserAndToken(us, x.Token);
                return(RedirectToPage("/Overview", new { id = 1 }));
            }
            else
            {
                return(RedirectToPage("/Index"));
            }
        }
Exemple #2
0
        public async Task <IActionResult> OnPost()
        {
            HttpRequests req = new HttpRequests();
            Object       u   = new
            {
                firstName   = Firstname,
                lastName    = Lastname,
                description = Description,
                street      = Street,
                zipCode     = ZipCode,
                city        = City,
                country     = Country,
            };
            HttpStatusCode c = await req.UpdateUserAsync(u, BaseController.GetToken());

            if (c == HttpStatusCode.OK || c == HttpStatusCode.NoContent)
            {
                BaseController.SetUser(await req.GetUserAsync(BaseController.GetToken()));
                return(RedirectToPage("/UserSite"));
            }
            else
            {
                // Zeige Fehler an
                return(null);
            }
        }