static public void Initialize(int userId)
    {
        //
        achievsRead = false;
        //
        //init achievements manager
        if (!DataManager.isAchievInitialized)
        {
            AchievementsManager.Create();
        }

        //
        DebugLog("SET DATAPLATFORM PLUGIN, user is " + userId);
        //
        CurrentUser = UsersManager.FindUserById(userId);

        //init dataplatform
        int result = DataPlatformPlugin.InitializePlugin(0);

        DebugLog("DataPlatformPlugin is : " + result.ToString());
        //init usermanager
        //UsersManager.Create();

        //
        if (CurrentUser != null)
        {
            //
            DebugLog("SET ACHIEVEMENTS MANAGER : Current user ID is " + CurrentUser.Id + " Current user UID is " + CurrentUser.UID);
            DebugLog("CALLING ACHIEV CREATION ...");

            //
            DebugLog("CALLING CONSOLE UTILS CREATION ...");

            //
            DebugLog("CALLING SYNC ...");
            DebugLog("CALLING SYNC ACHIEV WITH TITLE ID : " + ConsoleUtilsManager.TitleIdInt());
            //
            AchievementsManager.GetAchievementsForTitleIdAsync
                (CurrentUser.Id
                , CurrentUser.UID
                , ConsoleUtilsManager.TitleIdInt()
                , AchievementType.All
                , false
                , UnityPlugin.AchievementOrderBy.TitleId
                , 0
                , 10
                , OnAchievementSnapshotReady);


            //
            DataManager.isAchievInitialized = true;
            DebugLog("ACHIEVS CREATION AND SYNC SUCCESSFUL");
        }
        else
        {
            DebugLog("ACHIEVS ERROR INITIALIZING : CURRENT USER IS NULL");
        }
    }
 public void CreatePendingUserIfDoesNotExist(UserInformation userInformation)
 {
     var existingUser = Mongo.Users.AsQueryable()
         .FirstOrDefault(u => u.ClaimedIdentifier == userInformation.ClaimedIdentifier);
     if (existingUser != null)
     {
         return;
     }
     var user = new User(userInformation);
     Mongo.Users.Insert(user);
 }
 public void InitializeForRequest()
 {
     if (!Authentication.IsAuthenticated)
     {
         return;
     }
     var name = HttpContext.Current.User.Identity.Name;
     User = Mongo.Users.AsQueryable().FirstOrDefault(u => u.ClaimedIdentifier == name);
     if (User == null)
     {
         FormsAuthentication.SignOut();
         throw new ApplicationException("User does not exist. Access denied.");
     }
     if (User.IsDisabled())
     {
         FormsAuthentication.SignOut();
         throw new ApplicationException(
             "Your account has been created but is not yet approved, please contact an administrator to complete the setup process.");
     }
 }
 public string SaveUser(User user, string delete = null)
 {
     if (IsDelete(delete))
     {
         Mongo.Users.Remove(user.Id);
         return "Deleted";
     }
     Mongo.Users.Save(user);
     return "Saved";
 }
예제 #5
0
        public async Task<ActionResult> ExternalLoginConfirmation(ExternalLoginConfirmationViewModel model, string returnUrl)
        {
            if (User.Identity.IsAuthenticated)
            {
                return RedirectToAction("Index", "Manage");
            }

            if (ModelState.IsValid)
            {
                // Get the information about the user from the external login provider
                var info = await AuthenticationManager.GetExternalLoginInfoAsync();
                if (info == null)
                {
                    return View("ExternalLoginFailure");
                }
                var user = new User { UserName = model.Email, Email = model.Email };
                var result = await UserManager.CreateAsync(user);
                if (result.Succeeded)
                {
                    result = await UserManager.AddLoginAsync(user.EntityKey, info.Login);
                    if (result.Succeeded)
                    {
                        await SignInManager.SignInAsync(user, isPersistent: false, rememberBrowser: false);
                        return RedirectToLocal(returnUrl);
                    }
                }
                AddErrors(result);
            }

            ViewBag.ReturnUrl = returnUrl;
            return View(model);
        }
예제 #6
0
        public async Task<ActionResult> Register(RegisterViewModel model)
        {
            if (ModelState.IsValid)
            {
                var user = new User { UserName = model.Email, Email = model.Email };
                var result = await UserManager.CreateAsync(user, model.Password);
                if (result.Succeeded)
                {
                    await SignInManager.SignInAsync(user, isPersistent:false, rememberBrowser:false);
                    
                    // For more information on how to enable account confirmation and password reset please visit http://go.microsoft.com/fwlink/?LinkID=320771
                    // Send an email with this link
                    // string code = await UserManager.GenerateEmailConfirmationTokenAsync(user.Id);
                    // var callbackUrl = Url.Action("ConfirmEmail", "Account", new { userId = user.Id, code = code }, protocol: Request.Url.Scheme);
                    // await UserManager.SendEmailAsync(user.Id, "Confirm your account", "Please confirm your account by clicking <a href=\"" + callbackUrl + "\">here</a>");

                    return RedirectToAction("Index", "Home");
                }
                AddErrors(result);
            }

            // If we got this far, something failed, redisplay form
            return View(model);
        }
예제 #7
0
 public AdminItem(User user)
 {
     Summary = user.Name + " - " + user.Role + (user.IsActive ? string.Empty : " - Inactive");
     AdminType = AdminFilters.AdminType.User;
     Id = user.Id;
 }