Esempio n. 1
0
 public bool UpdateUserWallet(string idUser, string wallet)
 {
     try {
         var user = _cosmosIdentityManage.FindUserByUserId(idUser);
         if (user.WalletAddress == string.Empty) //Si no tiene wallet
         {
             user.WalletAddress = wallet;
             user.IsMetamask    = true;
             _cosmosIdentityManage.UpSertApplicationUser(user);
         }
         return(true);
     }
     catch (Exception) {
         return(false);
     }
 }
Esempio n. 2
0
        public ActionResult ChangeRol(string rolName)
        {
            var currentUser  = UserManager.FindByName(User.Identity.Name);
            var rolCandidate = currentUser.Roles.FirstOrDefault(r => r.Name == rolName);

            if (rolCandidate != null)
            {
                currentUser.LastRolId = Convert.ToInt32(rolCandidate.Id);
                _cosmosIdentityManage.UpSertApplicationUser(currentUser);
                var authenticationManager = HttpContext.GetOwinContext().Authentication;

                // create a new identity from the old one
                var identity = new ClaimsIdentity(User.Identity);
                // update claim value
                identity.RemoveClaim(identity.FindFirst(@"http://schemas.microsoft.com/ws/2008/06/identity/claims/role"));
                identity.AddClaim(new Claim("http://schemas.microsoft.com/ws/2008/06/identity/claims/role", rolName));
                authenticationManager.AuthenticationResponseGrant =
                    new AuthenticationResponseGrant(
                        new ClaimsPrincipal(identity),
                        new AuthenticationProperties {
                    IsPersistent = true
                }
                        );
            }

            string realRol = _cosmosIdentityManage.GetRoles().Single(r => r.Id == currentUser.LastRolId.ToString()).Name;

            if (realRol.Contains(Roles.Advertiser.ToString()))
            {
                return(RedirectToAction("Advertiser", "Marketplace"));
            }
            else if (realRol.Contains(Roles.Publisher.ToString()))
            {
                return(RedirectToAction("Publisher", "Marketplace"));
            }

            return(RedirectToAction("Login"));
        }
Esempio n. 3
0
 public Task UpdateAsync(TUser user)
 {
     _cosmosIdentityManage.UpSertApplicationUser(user);
     this.user = null;
     return(Task.CompletedTask);
 }