Exemplo n.º 1
0
        public MyPrincipal(MyIdentity user, string connIP)
        {
            _roles = new List <string>();
            if (user == null)
            {
                throw new Exception("Profilo non autenticato");
            }

            try
            {
                _identity = user;

                try
                {
                    UserStore store = new UserStore();
                    _roles = store.GetRolesAsync(user).Result;
                }
                catch (Exception e0)
                {
                    throw new Exception("Username e/o Dipartimento e/o Password potrebbero essere errati");
                }

                _identity.NomeCognome = "";
                sede = "";
            }
            catch (Exception ex)
            {
                throw new Exception("Profilo non corretto - " + ex.Message);
            }
        }
Exemplo n.º 2
0
        public MyPrincipal(MyIdentity user)
        {
            _roles = new List <string>();

            if (user == null)
            {
                throw new Exception("Profilo non autenticato");
            }


            _identity = user;
        }
Exemplo n.º 3
0
        public static async Task <MyPrincipal> BuildNewIdentity(string username, string dipartimento, string password, string type)
        {
            UserStore   store     = new UserStore();
            RoleStore   roleStore = new RoleStore();
            MyPrincipal mp        = null;
            //LoginResp r = store.Authenticate(username, dipartimento, password);
            int    iduser       = 0;
            string passwordHash = await store.GetPasswordHashAsync(username, ref iduser);

            string digitPasswordSHA = MySecurityProvider.PlainToSHA256(password);

            if (digitPasswordSHA == passwordHash)
            {
                MyIdentity id = new MyIdentity(username, dipartimento, password, type);
                id.Id = iduser.ToString();
                mp    = new MyPrincipal(id, null);
            }
            else
            {
                MyIdentity id = new MyIdentity(username, dipartimento);
                mp = new MyPrincipal(id, null);
            }
            return(await Task.FromResult(mp));
        }
Exemplo n.º 4
0
        public Task <IList <string> > getRoles(MyIdentity user)
        {
            UserStore store = new UserStore();

            return(store.GetRolesAsync(user));
        }
Exemplo n.º 5
0
        public Task <bool> IsInRole(MyIdentity identity, string role)
        {
            UserStore store = new UserStore();

            return(store.IsInRoleAsync(identity, role));
        }