Exemplo n.º 1
0
        public async Task SignUpOauth(HttpRequest request, string id, string type)
        {
            var         oauthRequestToken = request.Form["Token"];
            GoogleOauth oauthInfo         = await storageService.CallJSON <GoogleOauth>("https://oauth2.googleapis.com/tokeninfo?id_token=" + oauthRequestToken); //GETS EMAIL FOR GOOGLE OAUTH

            var password = encryptionService.EncryptPassword("!!0_STREAMWORK_!!0");

            var profile = new Profile {
                Id                    = id,
                Name                  = oauthInfo.Name.Contains(' ') ? oauthInfo.Name.Replace(' ', '|') : oauthInfo.Name + "|",
                EmailAddress          = oauthInfo.Email,
                Username              = Request.Form["Username"],
                Password              = password,
                ProfileType           = type,
                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"])
            };

            if (type == "tutor")
            {
                profile.PayPalAddress = Request.Form["PayPalAddress"];
                await AddUs5AsFollowers(id);
            }

            await storageService.Save(id, profile);

            await cookieService.SignIn(Request.Form["Username"], encryptionService.DecryptPassword(password, "!!0_STREAMWORK_!!0"));
        }