public HttpResponseMessage Login(LoginViewModel objLoginModel)
        {
            try
            {
                var args = new string[4];
                args[0] = "192.168.1.15";
                args[1] = "testing123";
                args[2] = objLoginModel.UserName;
                args[3] = objLoginModel.UserPassword;

                if (args.Length != 4)
                {
                    Authenticate.ShowUsage();
                }

                try
                {
                    Authenticate.Authentication(args).Wait();
                }
                catch (Exception e)
                {
                    Console.WriteLine(e);
                }

                return(new HttpResponseMessage()
                {
                    Content = new StringContent("success")
                });
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }
예제 #2
0
        public string Login(LoginDTO _loginDTO)
        {
            try
            {
                //objRegisterDB.LoginUser(_loginDTO.UserName,_loginDTO.UserPassword);
                var args = new string[4];
                args[0] = "192.168.1.3";
                args[1] = "testing123";
                args[2] = _loginDTO.UserName;
                args[3] = _loginDTO.UserPassword;
                if (args.Length != 4)
                {
                    Authenticate.ShowUsage();
                }

                try
                {
                    Authenticate.Authentication(args).Wait();
                }
                catch (Exception e)
                {
                    throw e;
                }
            }
            catch (Exception ex)
            {
                throw ex;
            }

            return(null);
        }
예제 #3
0
        public ActionResult Authentication(User user)
        {
            var User = Authenticate.Authentication(user.email);

            if (User != null)
            {
                FormsAuthentication.SetAuthCookie(User.email, true);
                Response.StatusCode = (int)HttpStatusCode.OK;
                return(Content("Welcome to Super Simple Task Manager", MediaTypeNames.Text.Plain));
            }
            Response.StatusCode = (int)HttpStatusCode.BadRequest;
            return(Content("The user doesn't exist", MediaTypeNames.Text.Plain));
        }
예제 #4
0
 public string Post(Task t)
 {
     try
     {
         var user = Authenticate.Authentication(User.Identity.Name);
         t.currentProgress = 0;
         t.newTask         = true;
         return(Tasks.Create(t));
     }
     catch (Exception ex)
     {
         return(ex.Message);
     }
 }
예제 #5
0
        private void btnSubmit_Click(object sender, EventArgs e)
        {
            StudentMenuForm form = new StudentMenuForm(StaffId, permission);

            if (!Authenticate.Authentication(StaffId, permission))
            {
                return;
            }
            if (!string.IsNullOrEmpty(txtStudentName.Text) || !string.IsNullOrEmpty(txtContactNumber.Text))
            {
                int gender = -1;
                switch (cbGender.SelectedItem.ToString())
                {
                case "Male":
                {
                    gender = 0;
                    break;
                }

                case "Female":
                {
                    gender = 1;
                    break;
                }
                }
                bool registrationStatus = StudentBLL.RegisterStudent(txtStudentName.Text,
                                                                     (int)System.Enum.Parse(typeof(GradeEnum), cbGrade.SelectedValue.ToString()),
                                                                     DateTime.Parse(dtp1.Value.ToString(dateFormat)), Convert.ToInt32(txtContactNumber.Text), gender, StaffId);
                MessageBox.Show(registrationStatus
                    ? SportRegistrationSystem.lblRegisterSuccess
                    : SportRegistrationSystem.lblRegisterFailed);
                if (registrationStatus)
                {
                    form.Show();
                    this.Dispose();
                }
            }
        }
예제 #6
0
        public ActionResult Registration(User user)
        {
            var User = Authenticate.Authentication(user.email);

            if (User != null)
            {
                Response.StatusCode = (int)HttpStatusCode.BadRequest;
                return(Content("This email already exist", MediaTypeNames.Text.Plain));
            }

            if (Authenticate.TokenExist(user.email))
            {
                Response.StatusCode = (int)HttpStatusCode.BadRequest;
                return(Content("Validate this email with the token we already send you", MediaTypeNames.Text.Plain));
            }

            var token = Authenticate.CreateToken(user);

            General.SendEmailValidation(token.token, user.email);

            Response.StatusCode = (int)HttpStatusCode.OK;
            return(Content("A token has been send to you email. Please click in the url to confirm the token.", MediaTypeNames.Text.Plain));
        }