Beispiel #1
0
        public async Task <IActionResult> GetUserAsync([FromHeader] string Authorization, [FromBody] UserCred userCred)
        {
            string email       = tokenObj.GetNameClaims(Authorization);
            string password    = userCred.Password;
            string newPassword = userCred.newPassword;


            if (email == "" || password == "" || newPassword == "")
            {
                return(NotFound(JsonConvert.SerializeObject("Please enter all fields", Formatting.Indented)));
            }

            User user = await UserMethods.getUser(email);

            if (user == null)
            {
                return(NotFound(JsonConvert.SerializeObject("User does not exist", Formatting.Indented)));
            }

            if (!UserMethods.authUser(email, password))
            {
                return(NotFound(JsonConvert.SerializeObject("Wrong Password", Formatting.Indented)));
            }

            if (!(await UserMethods.ChangePass(email, password, newPassword)))
            {
                return(NotFound(JsonConvert.SerializeObject("Something went wrong", Formatting.Indented)));
            }

            string json = JsonConvert.SerializeObject("Password changed!", Formatting.Indented);

            return(Ok(json));
        }
Beispiel #2
0
        public async Task <IActionResult> GetWatchlistAsync([FromHeader] string Authorization)
        {
            Dictionary <string, string> dictionary = new Dictionary <string, string>();

            string email = tokenObj.GetNameClaims(Authorization);

            if (email == "")
            {
                dictionary.Add("Message:", "NotFound");
                dictionary.Add("Description:", "Please enter all fields");
                return(NotFound(JsonConvert.SerializeObject(dictionary, Formatting.Indented)));
            }

            if (await UserMethods.getUser(email) == null)
            {
                dictionary.Add("Message:", "NotFound");
                dictionary.Add("Description:", "User not found");
                return(NotFound(JsonConvert.SerializeObject(dictionary, Formatting.Indented)));
            }


            List <MovieFirebase> wl = await WatchListMethods.GetMoviesAsync(email);

            if (wl.Count == 0 || wl == null)
            {
                dictionary.Add("Message:", "NotFound");
                dictionary.Add("Description:", "WatchList is empty");
                return(NotFound(JsonConvert.SerializeObject(dictionary, Formatting.Indented)));
            }

            string json = JsonConvert.SerializeObject(wl, Formatting.Indented);

            return(Ok(json));
        }
Beispiel #3
0
        public async Task <IActionResult> PostUserAsync([FromBody] UserCred userCred)
        {
            var name     = userCred.Name;
            var email    = userCred.Email;
            var password = userCred.Password;

            // validate fields
            if (name == null || email == null || password == null)
            {
                return(NotFound(JsonConvert.SerializeObject("Please enter all fields", Formatting.Indented)));
            }


            // check  if user exists
            if (await UserMethods.getUser(email) != null)
            {
                return(NotFound(JsonConvert.SerializeObject("User already exists", Formatting.Indented)));
            }

            //check if user saved
            bool savedUser = await UserMethods.insertUserAsync(name, email, password);

            if (!savedUser)
            {
                return(NotFound(JsonConvert.SerializeObject("Something went wrong saving the user", Formatting.Indented)));
            }

            return(Ok("200: description: Successfully inserted user"));
        }
Beispiel #4
0
        public async Task <IActionResult> LoginAsync([FromBody] UserCred userCred)
        {
            var email    = userCred.Email;
            var password = userCred.Password;


            //validate fields
            if (email == "" || password == "")
            {
                return(NotFound(JsonConvert.SerializeObject("Please enter all fields", Formatting.Indented)));
            }
            //validate user
            var token = jwtAuthenticationManager.Authenticate(email, password);

            if (token == null)
            {
                return(Unauthorized(JsonConvert.SerializeObject("Invalid credentials", Formatting.Indented)));
            }

            User user = await UserMethods.getUser(email);

            tokenObj      sendToken = new tokenObj(token);
            List <object> objects   = new List <object>();

            user.UserPassword = null;
            objects.Add(sendToken);
            objects.Add(user);
            return(Ok(JsonConvert.SerializeObject(objects, Formatting.Indented)));
        }
Beispiel #5
0
        [Fact]//Repository.HaikuRepo.cs
        public void HaikuRepoTest3()
        {
            HaikuRepo haikurepo = new HaikuRepo(hContext);
            HaikuLine haikuline = new HaikuLine();

            haikuline.Line     = "I can not live without it";
            haikuline.Tags     = "life silly";
            haikuline.Syllable = 7;
            haikuline.Approved = true;
            haikuline.Username = "******";
            RawUser rawuser = new RawUser();

            rawuser.Username  = "******";
            rawuser.FirstName = "Chris";
            rawuser.LastName  = "Larson";
            rawuser.Password  = "******";
            UserRepo    userrepo    = new UserRepo(hContext);
            UserMethods usermethods = new UserMethods(userrepo);
            User        user        = usermethods.GetUser(rawuser.Username);

            haikuline.User = user;
            var actual   = haikurepo.SaveLine(haikuline).Username;
            var expected = "Chris123";

            Assert.Equal(expected, actual);
        }
Beispiel #6
0
        async void OnbtnLoginClicked(object sender, EventArgs e)
        {
            var m = new UserMethods();

            if (g.signIn)
            {
                var s = await m.SignOut(g);
            }
            else
            {
                var mth = new Methodlar();


                if (g.signIn)
                {
                }
                else
                {
                    if (g.checkDbUser)
                    {
                        g.usernameEntry.Text = g.user.user;
                        g.passwordEntry.Text = g.user.pass;
                        g.custEntry.Text     = g.user.cust;
                        g.cpssEntry.Text     = g.user.cpss;
                        g.rememberSwt.On     = g.user.remember;
                        g.savepassSwt.On     = g.user.save;
                    }


                    LoginPage loginp = new LoginPage(g);

                    await g.mdp.Detail.Navigation.PushAsync(loginp);
                }
            }
        }
Beispiel #7
0
        public void AddStudent(String StudentName, String StudentAdress, String StudentMail, String StudentPhone, String StudentUsername, String Password, String CourseId)
        {
            User user = new User();

            user.FullName    = StudentName;
            user.Adress      = StudentAdress;
            user.UserID      = Guid.NewGuid();
            user.StudentID   = Guid.NewGuid();
            user.Password    = Password;
            user.Mail        = StudentMail;
            user.Username    = StudentUsername;
            user.PhoneNumber = StudentPhone;
            Student stu = new Student();

            stu.StudentId = (Guid)user.StudentID;
            stu.GPA       = 0;
            Transcript trans = new Transcript();

            trans.cid      = Int32.Parse(CourseId);
            trans.GPA      = 0;
            trans.Semester = "2018 Fall";
            stu.Transcript.Add(trans);
            user.Student = stu;
            var result = UserMethods.AddUser(user);

            if (result == true)
            {
                ViewBag.Added = true;
            }
            Response.Redirect("/Teacher/RegisterStudent");
        }
Beispiel #8
0
        [Fact]//Repository.HaikuRepo.cs
        public void HaikuRepoTest1()
        {
            HaikuRepo haikurepo = new HaikuRepo(hContext);
            HaikuLine haikuline = new HaikuLine();

            haikuline.Line     = "Coffee is my life";
            haikuline.Tags     = "coffee life silly";
            haikuline.Syllable = 5;
            haikuline.Approved = false;
            haikuline.Username = "******";
            RawUser rawuser = new RawUser();

            rawuser.Username  = "******";
            rawuser.FirstName = "Chris";
            rawuser.LastName  = "Larson";
            rawuser.Password  = "******";
            UserRepo    userrepo    = new UserRepo(hContext);
            UserMethods usermethods = new UserMethods(userrepo);
            User        user        = usermethods.UserRegister(rawuser);

            haikuline.User = user;
            var actual   = haikurepo.SaveLine(haikuline).Username;
            var expected = "Chris123";

            Assert.Equal(expected, actual);
        }
 public static void ClassInit(TestContext testContext)
 {
     user = new UserMethods(debugLog);
     XmlConfigurator.Configure();
     Application.EnableVisualStyles();
     Application.SetCompatibleTextRenderingDefault(false);
 }
Beispiel #10
0
        public ActionResult UpdateProfile(tbl_Users request, int?RequestId = null)
        {
            //var flag = new UserDataAccess().UpdateUser(request);
            var getUserDetails   = UserMethods.GetUserDetailsByID(request.ID);
            var getSystemRequest = new SystemRequestDataAccess().GetSystemRequest(RequestId.GetValueOrDefault());

            request.UserPassword          = getUserDetails.UserPassword;
            request.AuthorizationStatus   = getUserDetails.AuthorizationStatus;
            request.AuthorizationComments = getUserDetails.AuthorizationComments;

            var existingJson = getUserDetails == null ? null : CustomHelper.GetJson(getUserDetails);

            var updatedJson = CustomHelper.GetJson(request);
            var row         = new tbl_System_Requests
            {
                ID = RequestId ?? 0,
                AuthorizationStatus   = "P",
                CreatorID             = StateHelper.UserId,
                IsActive              = true,
                ExistingData          = existingJson,
                UpdatedData           = updatedJson,
                RequestType           = Constants.RequestTypes.UserModification,
                AuthorizerID          = getSystemRequest?.AuthorizerID ?? 0,
                AuthorizationComments = getSystemRequest?.AuthorizationComments ?? string.Empty
            };

            var flag = (!RequestId.HasValue || RequestId.GetValueOrDefault() <= 0) ? new SystemRequestDataAccess().AddSystemRequest(row) : new SystemRequestDataAccess().UpdateSystemRequest(row);

            return(Json(new { IsSuccess = flag, ErrorMessage = (flag == true) ? CustomMessages.UserProfileUpdateSuccessfully : CustomMessages.GenericErrorMessage }, JsonRequestBehavior.AllowGet));
        }
Beispiel #11
0
        void OnbtnChangePassClicked(object sender, EventArgs e)
        {
            ServiceManager sm = new ServiceManager();
            var            m  = new UserMethods();


            if (g.usernameEntry.Text == "" || g.passwordEntry.Text == "")
            {
                this.DisplayAlert("User Name Error", "Please Enter your POSDA account name", "OK");
            }
            else
            {
                g = m.dbCheckUser(g).Result;

                //var signResult = m.SignInOut(g, 0).Result;

                if (g.signIn)
                {
                    ChangePassPage cp = new ChangePassPage(g);

                    g.mdp.Detail.Navigation.PushAsync(cp);
                }
                //else
                //{
                //    await parentpage.DisplayAlert("Error", "Failed Sign In", "OK");

                //}
            }
        }
 protected void Page_Load(object sender, EventArgs e)
 {
     if (!IsPostBack)
     {
         //if (Application["user"] != null)
         //{
         if (!string.IsNullOrEmpty(Request.QueryString["Code"]))
         {
             this.ClientScript.RegisterStartupScript(this.GetType(), "", "displayUserEditdiv();", true);
             UserInfo info          = UserMethods.GetUserByCode(Request.QueryString["Code"]);
             string   desecpassword = FBJHelper.Encryption.DESEdcrypt(info.Password, "19850627");
             info.Password = desecpassword;
             Initialize(info);
         }
         else
         {
             this.ClientScript.RegisterStartupScript(this.GetType(), "", "displayUserSet();", true);
         }
         BindDataGrid(queryList);
         //}
         //else
         //{
         //    Response.Redirect("~/Views/Login.aspx");
         //    Alert.Show(this, "请先登录!");
         //}
     }
 }
        protected void UserListDataGrid_ItemCommand(object source, DataGridCommandEventArgs e)
        {
            string id = string.Empty;

            if (e.CommandName == "ImageDelete")
            {
                int selectindex = e.Item.ItemIndex;
                id = this.UserListDataGrid.Items[selectindex].Cells[0].Text;
            }
            if (!string.IsNullOrEmpty(id) && this.deleteflag == true)
            {
                int iSuccess = UserMethods.DeleteUser(Convert.ToInt32(id));
                if (iSuccess > 0)
                {
                    Alert.Show(this, "删除成功!");
                }
                else
                {
                    Alert.Show(this, "删除失败!");
                }
                if (queryList == null)
                {
                    queryList = new List <QueryElement>();
                }
                BindDataGrid(queryList);
            }
        }
        public ActionResult Resources()
        {
            ViewBag.User = (User)Session["User"];
            User user = (User)Session["User"];

            ViewBag.Resources = UserMethods.GetResources(user.UserID);
            return(View("Resources"));
        }
        public ActionResult VacationDays()
        {
            User user = (User)Session["User"];

            ViewBag.User        = (User)Session["User"];
            ViewBag.VacationDay = UserMethods.GetVacationDays(user.UserID);
            return(View("VacationDays"));
        }
        public ActionResult ListForumEntries(int forumid)
        {
            ViewBag.User = (User)Session["User"];
            var result = UserMethods.GetForumEntries(forumid);

            ViewBag.ForumContent = result;
            return(View("ForumTopic"));
        }
        public MasterDetail()
        {
            var glb = new POSDA.GlobalVar.GlobalDegisken();
            var mth = new Methodlar();
            var um  = new UserMethods();

            glb.mdp         = this;
            glb.datePeriod  = 2;
            glb.signIn      = false;
            glb.checkDbUser = false;


            try
            {
                glb = um.dbCheckUser(glb).Result;

                if (glb.checkDbUser)
                {
                    if (glb.user.save)
                    {
                        glb = um.SignIn(glb).Result;

                        if (glb.signIn)
                        {
                        }
                        else
                        {
                            int i = um.SignOut(glb).Result;
                        }
                    }
                }
                else
                {
                }
            }
            catch (Exception)
            {
                throw;
            }
            finally
            {
                Master = new MenuPage(glb)
                {
                    Title           = " ",
                    Padding         = new Thickness(0, Device.OS == TargetPlatform.iOS ? 20 : 0, 0, 0),
                    BackgroundColor = Color.Aqua
                };
                WelcomePage wp = new WelcomePage(glb);
                glb.activep = wp;
                glb.prevp   = null;
                Detail      = new NavigationPage(wp)
                {
                    BarBackgroundColor = Color.Aqua,
                    BarTextColor       = Color.Black,
                    Padding            = new Thickness(5, Device.OS == TargetPlatform.iOS ? 20 : 0, 5, 5),
                };
            }
        }
Beispiel #18
0
        [Fact] //BusinessLogic.UserMethods.cs
        public void UserMethodsTest3()
        {
            UserRepo    userrepo    = new UserRepo(hContext);
            UserMethods usermethods = new UserMethods(userrepo);
            var         expected    = false;
            var         actual      = usermethods.UpdatePassword("clarson", "123cherrytree", "99redballoons");

            Assert.Equal(expected, actual);
        }
        public ActionResult ListForums()
        {
            ViewBag.User = (User)Session["User"];
            User user   = (User)Session["User"];
            var  result = UserMethods.GetForums(user.UserID);

            ViewBag.Forums = result;
            return(View("Forums"));
        }
Beispiel #20
0
        [Fact] //BusinessLogic.UserMethods.cs
        public void UserMethodsTest2()
        {
            UserRepo    userrepo    = new UserRepo(hContext);
            UserMethods usermethods = new UserMethods(userrepo);
            User        expected    = null;
            User        actual      = usermethods.UserLogin("clarson217", "12345");

            Assert.Equal(expected, actual);
        }
 private void BindDataGrid(List <QueryElement> list)
 {
     userColl = UserMethods.GetUser(list);
     this.UserListDataGrid.DataSource = userColl;
     this.UserListDataGrid.DataBind();
     for (int i = 0; i < userColl.Count; i++)
     {
         this.UserListDataGrid.Items[i].Cells[4].Text = StaticRescourse.DisplayRole(userColl[i].Role);
     }
 }
Beispiel #22
0
        static void Main(string[] args)
        {
            StringMethods stringMethods = new StringMethods();
            UserMethods   userMethods   = new UserMethods(stringMethods);

            Client client = new Client(stringMethods, userMethods);
            Chat   chat   = new Chat(stringMethods, userMethods);

            chat.P2PChat(client);
        }
 public ActionResult Schedule(string uid = null)
 {
     if (uid == null)
     {
         User user = (User)Session["User"];
         ViewBag.User         = (User)Session["User"];
         ViewBag.ScheduleList = UserMethods.GetSchedule(user.UserID);
         return(View("Schedule"));
     }
 }
Beispiel #24
0
        [Fact]//Controllers.UserController.cs
        public void UserControllerTest5()
        {
            UserRepo       userrepo       = new UserRepo(hContext);
            UserMethods    userMethods    = new UserMethods(userrepo);
            UserController userController = new UserController(userMethods);
            var            actionList     = userController.GellAllUser();
            var            expected       = true;
            var            actual         = (actionList.Value.ToList() != null);

            Assert.Equal(expected, actual);
        }
Beispiel #25
0
        [Fact]//Controllers.UserController.cs
        public void UserControllerTest3()
        {
            UserRepo       userrepo       = new UserRepo(hContext);
            UserMethods    userMethods    = new UserMethods(userrepo);
            UserController userController = new UserController(userMethods);
            var            actionUser     = userController.Getuser("clarson");
            var            expected       = "*****@*****.**";
            var            actual         = actionUser.Value.Email;

            Assert.Equal(expected, actual);
        }
Beispiel #26
0
        public String Login(string username, string password)
        {
            var result = UserMethods.Login(username, password);

            if (result != null)
            {
                Session["User"] = result;
                user            = result;
            }
            return(JsonConvert.SerializeObject(result, Formatting.Indented));
        }
Beispiel #27
0
        public void QuadrupleTheIntReturnsQuadrupleTheInt()
        {
            // arrange
            var businessClass = new UserMethods();
            int x             = 4;

            // act
            int result = businessClass.QuadrupleTheInt(x);

            // assert
            Assert.Equal(16, result);
        }
        public ActionResult ListUsers()
        {
            ViewBag.User = (User)Session["User"];
            User user     = (User)Session["User"];
            var  userList = UserMethods.GetUsersInDomain(user.UserID);

            ViewBag.ScheduleList = UserMethods.GetSchedule(user.UserID);
            if (userList != null)
            {
                ViewBag.UserList = userList;
            }
            return(View("List"));
        }
        public String SendMessage(string uidreciever, string message)
        {
            User    user = (User)Session["User"];
            Message mes  = new Message();

            mes.senderid   = user.UserID;
            mes.recieverid = Guid.Parse(uidreciever);
            mes.message1   = message;
            mes.CreateDate = DateTime.Now;
            var result = UserMethods.SendMessage(mes);

            return(JsonConvert.SerializeObject(result, Formatting.Indented));
        }
Beispiel #30
0
        public string AddUser(string identifier, string companyID)
        {
            UserMethods um = new UserMethods();

            try
            {
                int companyIDInt = Int32.Parse(companyID);
                return(um.AddUser(identifier, companyIDInt));
            }
            catch (Exception e)
            {
                return("bad");
            }
        }