Ejemplo n.º 1
0
        public async Task OnPostSignUpStudent()
        {
            string id = Guid.NewGuid().ToString();

            if (Request.Form.ContainsKey("Token"))
            {
                await SignUpOauth(Request, id, "student");
            }
            else
            {
                if (!await VerifyRequest(Request)) //TOM this wont work with google ouath. The email wont be populated becasue it gets it from an api call LOOK at SignUpOauth
                {
                    // JavaScript checks seeem to have been ignored!
                    // Potential attack detected. Aborting.
                    return;
                }

                Profile user = new Profile
                {
                    Id                    = id,
                    Name                  = Request.Form["FirstName"] + "|" + Request.Form["LastName"],
                    EmailAddress          = Request.Form["EmailAddress"],
                    Username              = Request.Form["Username"],
                    Password              = encryptionService.EncryptPassword(Request.Form["Password"]),
                    ProfileType           = "student",
                    College               = Request.Form["SchoolName"],
                    NotificationSubscribe = "True",
                    Expiration            = DateTime.UtcNow,
                    AcceptedTutor         = false,
                    LastLogin             = DateTime.UtcNow,
                    ProfileColor          = MiscHelperMethods.GetRandomColor(),
                    ProfileSince          = DateTime.UtcNow,
                    ProfilePicture        = MiscHelperMethods.defaultProfilePicture,
                    ProfileBanner         = MiscHelperMethods.defaultBanner,
                    TimeZone              = MiscHelperMethods.GetTimeZoneBasedOfOffset(Request.Form["Time"])
                };

                await storageService.Save(user.Id, user);

                await cookieService.SignIn(Request.Form["Username"], encryptionService.DecryptPassword(user.Password, Request.Form["Password"]));
            }

            topicService.FollowTopics(Request.Form["Username"], GetAllSelectedTopics(Request.Form["Topics"].ToString().Split('|')));
            await emailService.SendTemplateToStreamwork("studentSignUp", await storageService.Get <Profile>(SQLQueries.GetUserWithUsername, Request.Form["Username"]), Request.Form.Files);
        }