Beispiel #1
0
 public UserLoginException(
     UserLoginErrorCode errorCode,
     WebLogin loginInstance) : base(GetMessage(errorCode))
 {
     ErrorCode = errorCode;
     UserLogin = loginInstance;
 }
Beispiel #2
0
        public object AuthenticateFromWeb([FromBody] WebLogin user)
        {
            if (user == null)
            {
                return(BadRequest("Ange användare"));
            }

            if (user.Role == Constants.UserRole || user.Role == Constants.AdminRole)
            {
                var claims = new List <Claim>();
                claims.Add(new Claim("username", user.UserName));
                claims.Add(new Claim(ClaimTypes.Role, user.Role));

                var token = JwtHelper.GetJwtToken(
                    user.UserName,
                    Constants.uniqueKey,
                    Constants.localAdress,
                    Constants.localAdress,
                    TimeSpan.FromMinutes(60),
                    claims.ToArray());

                return(new
                {
                    token = new JwtSecurityTokenHandler().WriteToken(token),
                    expires = token.ValidTo
                });
            }
            else
            {
                return(BadRequest("Ogiltig roll"));
            }
        }
Beispiel #3
0
        public LoginResponse WebLogin(string userName, string passwrod, string returnUrl, string keepMeSignedIn)
        {
            var webLogin = new WebLogin();
            var model    = webLogin.Login(userName, passwrod, returnUrl, keepMeSignedIn);

            return(model);
        }
Beispiel #4
0
    public void ClickLogin()
    {
        WebLogin Login = new WebLogin();

        Login.id       = loginIdText.GetComponent <Text>().text;
        Login.password = loginPwText.text;

        NetWWW.INSTANCE().Send(Login, true);
    }
Beispiel #5
0
        public async Task <string> Handle(GetTokenQuery request, CancellationToken cancellationToken)
        {
            WebLogin user = new WebLogin
            {
                UserName = request.UserName,
                Role     = request.Role
            };

            return(await _repository.GenerateToken(user));
        }
Beispiel #6
0
        public static bool LoginUser(string name)
        {
            var loginRequest = new WebLogin(name);
            var result       = loginRequest.Request();

            if (result.Status == WebRequestStatus.Failed)
            {
            }

            return(result.Status == WebRequestStatus.Ok);
        }
Beispiel #7
0
 public IActionResult UserLogin([FromBody] WebLogin webLogin)
 {
     try
     {
         return(Json(_loginService.Login(webLogin)));
     }
     catch (Exception ex)
     {
     }
     return(BadRequest());
 }
Beispiel #8
0
        /// <summary>
        /// Insert WebLogIn登入訊息(成功)
        /// </summary>
        /// <param name="cusrName">欲帳號Tuser Object</param>
        /// <param name="cname">登入者姓名</param>
        ///
        public void CreateWebLogin(Tuser tuser, string IpAddress)
        {
            var webLogin = new WebLogin
            {
                Cdate     = DateTime.Now,
                Cname     = tuser.Cname,
                CusrName  = tuser.CusrName,
                Issuccess = true,
                IpAddress = IpAddress
            };

            this.webLoginRepository.Create(webLogin);
        }
Beispiel #9
0
        /// <summary>
        /// Insert WebLogIn登入訊息(失敗)
        /// </summary>
        /// <param name="cusrName">登入者輸入的帳號</param>
        ///
        public void CreateWebLogin(string cusrName, string IpAddress)
        {
            var webLogin = new WebLogin
            {
                Cdate     = DateTime.Now,
                Cname     = "",
                CusrName  = cusrName,
                Issuccess = false,
                IpAddress = IpAddress
            };

            this.webLoginRepository.Create(webLogin);
        }
        public IActionResult Submit(string myUsername, string myPassword)
        {
            WebLogin webLogin = new WebLogin("Server=10.16.112.118;Database=db1120622_TMFfund;Uid=u1120622_TMFfund;Pwd=nsccDonorProject@2020;SslMode=none;", HttpContext);

            webLogin.username = myUsername;
            webLogin.password = myPassword;
            //do I have access?
            if (webLogin.unlock())
            {
                //access granted
                return(RedirectToAction("Index", "Home"));
            }
            else
            {
                //access denied
                ViewData["feedback"] = "Incorrect login. Please try again...";
            }
            return(View("Index"));
        }
Beispiel #11
0
        public CustomerRegisterLoginViewModel Login(WebLogin webLogin)
        {
            CustomerWebAccount             customerWebAccount             = _valkyraRegisterRepository.GetAccountForLogin(webLogin);
            CustomerRegisterLoginViewModel customerRegisterLoginViewModel = new CustomerRegisterLoginViewModel();

            customerRegisterLoginViewModel.FunctionName = "LoginResult";
            if (customerWebAccount == null)
            {
                customerRegisterLoginViewModel.ValidationResultMessage = "Username or password wrong!";
            }
            else
            {
                CustomerWebToken customerWebToken = _valkyraRegisterRepository.CreateToken(customerWebAccount);
                customerRegisterLoginViewModel.Token      = customerWebToken.Token;
                customerRegisterLoginViewModel.Expire     = customerWebToken.Expire;
                customerRegisterLoginViewModel.CustomerId = customerWebAccount.Customer.Id;
            }
            return(customerRegisterLoginViewModel);
        }
Beispiel #12
0
        public IActionResult Submit(string myUsername, string myPassword)
        {
            WebLogin webLogin = new WebLogin("Server=localhost;Database=dbCTP;Uid=root;Pwd=;SslMode=none;", HttpContext);

            webLogin.username = myUsername;
            webLogin.password = myPassword;
            //do I have access?
            if (webLogin.unlock())
            {
                //access granted
                Console.WriteLine("\n\n\nSession Auth: " + HttpContext.Session.GetString("auth"));
                return(RedirectToAction("Index", "Admin"));
            }
            else
            {
                //access denied
                ViewData["feedback"] = "Incorrect login. Please try again...";
            }
            return(View("Index"));
        }
        public IActionResult Submit(string myUsername, string myPassword)
        {
            WebLogin webLogin = new WebLogin("Database=weatherb_dotNetCoreSamples;Data Source=db.nscctruro.ca;User Id=weatherb_Admin;Password=mySQLpassword123;SslMode=None"
                                             , "tbllogin", HttpContext);

            webLogin.username = myUsername;
            webLogin.password = myPassword;

            // login attempt
            if (webLogin.unlock())
            {
                return(RedirectToAction("Index", "Home"));
            }
            else
            {
                ViewData["feedback"] = "Incorrect Login. Try again loser...";
            }

            return(View("Index"));
        }
        public IActionResult Submit(string myUsername, string myPassword)
        {
            WebLogin webLogin = new WebLogin("Server=localhost; Database=grades;Uid=shoaib;Pwd=password;SslMode=none;", HttpContext);

            webLogin.username = myUsername;
            webLogin.password = myPassword;

            // do I have access?
            if (webLogin.unlock())
            {
                // access granted
                return(RedirectToAction("Index", "Home"));
            }
            else
            {
                // access denied
                ViewData["feedback"] = "Incorrect login. Please try again...";
            }

            return(View("Index"));
        }
Beispiel #15
0
        public async Task <string> GenerateToken(WebLogin user)
        {
            string url = Constants.urlToken;

            try
            {
                using (HttpClient client = new HttpClient())
                {
                    var response = client.PostAsJsonAsync(url, user).Result;

                    var json = await response.Content.ReadAsStringAsync();

                    UserToken token = JsonConvert.DeserializeObject <UserToken>(json);

                    return(token.token);
                }
            }
            catch (Exception ex)
            {
                return(null);
            }
        }
Beispiel #16
0
        public HttpResponseMessage PostLogin(WebLogin login)
        {
            if (!ModelState.IsValid || login == null)
            {
                return(Request.CreateResponse(HttpStatusCode.BadRequest, ModelState));
            }

            try
            {
                Random random = new Random();
                Thread.Sleep(random.Next(2000));
                int id = repo.attemptLogin(login);

                FormsAuthentication.SetAuthCookie(id.ToString(), login.rememberMe);
                return(Request.CreateResponse(HttpStatusCode.Created, id));
            }
            catch (Exception e)
            {
                FormsAuthentication.SignOut();
                Thread.Sleep(2000);
                return(Request.CreateResponse(HttpStatusCode.BadRequest, e));
            }
        }
Beispiel #17
0
    protected void Page_Load(object sender, EventArgs e)
    {
        // weblogin object
        if (Session["login"] != null)
        {
            login = (WebLogin)Session["login"];

            // redirect if already logged in
            if (login.unlock() != "no")
            {
                sendAway();
            }
        }
        else
        {
            // build object and then save in session
            login            = new WebLogin("rehberga_php", "rehberga_nsccweb", "Normandy2492*", "login");
            Session["login"] = login;
        }

        // set event listeners
        btnSubmit.Click += new EventHandler(onSub);
    }
		public int attemptLogin(WebLogin login)
		{
			User user = db.Users
				.SingleOrDefault(u => u.email == login.email);

			if (user != null)
			{
				checkConditions(user);
				if (Passwords.authenticateUser(user, login.password))
				{
					db.SaveChanges();
					return user.id;
				}
				else
				{
					throw new Exception("Invalid password");
				}
			}
			else
			{
				throw new Exception("Invalid email address");
			}
		}
    protected void Page_Load(object sender, EventArgs e)
    {
        // login check
        if (Session["login"] == null)
        {
            // redirect
            Response.Redirect("index.aspx");
        }
        else if (((WebLogin)Session["login"]).access == "no")
        {
            // redirect
            Response.Redirect("index.aspx");
        }
        else
        {
            login = (WebLogin)Session["login"];
        }

        // maintain page position after hitting edit and apply buttons
        //Page.MaintainScrollPositionOnPostBack = true;

        // build regex objects for input validation
        regexText = new Regex("^[A-Z\\'][a-zA-Z\\s\\'\\-\\,\\.]+$");

        // hide and disable elements that aren't meant to be displayed until accept or decline is click
        divApprove.Visible = false;
        divDenied.Visible  = false;

        // populate textboxes and labels with data from database
        getData();

        // event listeners
        btnAccept.Click  += new EventHandler(btnApprove_Click);
        btnDecline.Click += new EventHandler(btnDeny_Click);
        btnLogout.Click  += new EventHandler(logout);
    }
Beispiel #20
0
        public IActionResult Submit(string myUsername, string myPassword)
        {
            try{
                WebLogin webLogin = new WebLogin("Server=localhost;Database=dotnetcoreSamples;Uid=root;Pwd=;SslMode=none;", HttpContext);
                webLogin.username = myUsername;
                webLogin.password = myPassword;

                // do I have access?
                if (webLogin.unlock())
                {
                    //access granted
                    return(RedirectToAction("Index", "Admin"));
                }
                else
                {
                    // access denied
                    ViewData["feedback"] = "Incorrect login. Please try again...";
                }

                return(View("Index"));
            } catch (Exception e) {
                return(Content(e.Message));
            }
        }
Beispiel #21
0
 private void Awake()
 {
     Instance = this;
 }
Beispiel #22
0
    // ---------------------------------------------------------------- event handlers

    private void logout(object sender, EventArgs e)
    {
        login            = null;
        Session["login"] = null;
        Response.Redirect("index.aspx");
    }
Beispiel #23
0
    void OnGUI()
    {
        if (_bMsgbox)
        {
            GUI.Box(new Rect(Screen.width / 4, Screen.height / 4, Screen.width / 2, Screen.height / 2), _szMsg);
            if (GUI.Button(new Rect(Screen.width / 2 - 50, Screen.height - Screen.height / 4, 100, 50), "OK"))
            {
                _bMsgbox    = false;
                GUI.enabled = true;
            }
            GUI.enabled = false;
        }
        else
        {
            GUI.enabled = !_bBlockinput;
        }

        GUI.Box(new Rect(10, 10, 150, 180), "Loader Menu");
        {
            if (GUI.Button(new Rect(20, 40, 130, 20), "회원가입"))
            {
                // MonoBehaviour를 상속받지 않은 일반 클래스
                // C#의 모든 객체는 동적할당해야 사용 가능. 할당된 객체는 Garbage Collector에 의해 자동으로 파괴
                WebRegister Reg = new WebRegister();

                Reg.id       = this.id;
                Reg.password = this.password;

                // 내부에서 코루틴 함수 호출
                NetWWW.INSTANCE().Send(Reg, true);
                // TODO: !!주의!! 유니티 코루틴 사용 시 참고 사항
                // 이 부분에서 STartCoroutine()을 직접 호출해선 안됨.
                // 1. 코루틴 종료가 늦어지거나 설계상의 문제로 종료되지 않을 경우, 메모리 정리를 하지 않기 때문에 가끔씩 튐
                // 2. 양적으로 많아지면 매 프레임마다 다 들려야 하므로 느려짐
                // -> 라이브에서는 해당 예제처럼 객체들을 각각의 패킷으로 여기고 직렬화하여 직렬화하여 순차적으로 전송해야함 (디자인 패턴 중 Command Pattern 참고)
            }
            if (GUI.Button(new Rect(20, 40 + 30, 130, 20), "로그인"))
            {
                WebLogin Login = new WebLogin();

                Login.id       = this.id;
                Login.password = this.password;

                NetWWW.INSTANCE().Send(Login, true);
            }
            if (GUI.Button(new Rect(20, 40 + 60, 130, 20), "유저 정보"))
            {
                WebUserInfo Info = new WebUserInfo();

                Info.accountno = this.accountno;
                Info.session   = this.session;

                NetWWW.INSTANCE().Send(Info, true);
            }

            if (GUI.Button(new Rect(20, 40 + 90, 130, 20), "세션 갱신"))
            {
                WebSession Session = new WebSession();

                Session.accountno = this.accountno;
                Session.session   = this.session;

                NetWWW.INSTANCE().Send(Session, true);
            }

            if (GUI.Button(new Rect(20, 40 + 120, 130, 20), "스테이지 클리어"))
            {
                WebStageClear Clear = new WebStageClear();

                Clear.accountno = this.accountno;
                Clear.session   = this.session;
                Clear.stageid   = this.stageid;

                NetWWW.INSTANCE().Send(Clear, true);
            }
        }

        GUI.enabled = true;
    }
Beispiel #24
0
 public CustomerWebAccount GetAccountForLogin(WebLogin webLogin)
 {
     return(_dbContext.WebAccounts.Include("Customer").FirstOrDefault(x => x.Password == StringToHash(webLogin.Password) && x.Email == webLogin.Email));
 }