public void SaveUserAuth(IAuthSession authSession)
        {
            using (_session)
            {
                int idInt = int.Parse(authSession.UserAuthId);

                var userAuth = !authSession.UserAuthId.IsNullOrEmpty()
                                   ? _session.Load <UserAuth>(idInt)
                                   : authSession.ConvertTo <UserAuth>();

                if (userAuth.Id == default(int) && !authSession.UserAuthId.IsNullOrEmpty())
                {
                    userAuth.Id = idInt;
                }

                userAuth.ModifiedDate = DateTime.UtcNow;
                if (userAuth.CreatedDate == default(DateTime))
                {
                    userAuth.CreatedDate = userAuth.ModifiedDate;
                }

                _session.Store(userAuth);
                _session.SaveChanges();
            }
        }
        public virtual async Task SaveUserAuthAsync(IAuthSession authSession, CancellationToken token = default)
        {
            if (authSession == null)
            {
                throw new ArgumentNullException(nameof(authSession));
            }

            await ExecAsync(async db =>
            {
                var userAuth = !authSession.UserAuthId.IsNullOrEmpty()
                    ? await db.SingleByIdAsync <TUserAuth>(int.Parse(authSession.UserAuthId), token).ConfigAwait()
                    : authSession.ConvertTo <TUserAuth>();

                if (userAuth.Id == default && !authSession.UserAuthId.IsNullOrEmpty())
                {
                    userAuth.Id = int.Parse(authSession.UserAuthId);
                }

                userAuth.ModifiedDate = DateTime.UtcNow;
                if (userAuth.CreatedDate == default)
                {
                    userAuth.CreatedDate = userAuth.ModifiedDate;
                }

                await db.SaveAsync(userAuth, token: token).ConfigAwait();
            }).ConfigAwait();
        }
Example #3
0
        public virtual void SaveUserAuth(IAuthSession authSession)
        {
            if (authSession == null)
            {
                throw new ArgumentNullException(nameof(authSession));
            }

            Exec(db =>
            {
                var userAuth = !authSession.UserAuthId.IsNullOrEmpty()
                    ? db.SingleById <TUserAuth>(int.Parse(authSession.UserAuthId))
                    : authSession.ConvertTo <TUserAuth>();

                if (userAuth.Id == default(int) && !authSession.UserAuthId.IsNullOrEmpty())
                {
                    userAuth.Id = int.Parse(authSession.UserAuthId);
                }

                userAuth.ModifiedDate = DateTime.UtcNow;
                if (userAuth.CreatedDate == default(DateTime))
                {
                    userAuth.CreatedDate = userAuth.ModifiedDate;
                }

                db.Save(userAuth);
            });
        }
        public override void OnAuthenticated(IServiceBase authService, IAuthSession session, IAuthTokens tokens, Dictionary <string, string> authInfo)
        {
            base.OnAuthenticated(authService, session, tokens, authInfo);

            //Populate all matching fields from this session to your own custom User table
            var user = session.ConvertTo <User>();

            user.Id = int.Parse(session.UserAuthId);
            user.GravatarImageUrl64 = !session.Email.IsNullOrEmpty()
                ? CreateGravatarUrl(session.Email, 64)
                : null;

            foreach (var authToken in session.ProviderOAuthAccess)
            {
                if (authToken.Provider == FacebookAuthProvider.Name)
                {
                    user.FacebookName      = authToken.DisplayName;
                    user.FacebookFirstName = authToken.FirstName;
                    user.FacebookLastName  = authToken.LastName;
                    user.FacebookEmail     = authToken.Email;
                }
                else if (authToken.Provider == TwitterAuthProvider.Name)
                {
                    user.TwitterName = user.DisplayName = authToken.UserName;
                }
                else if (authToken.Provider == GoogleOpenIdOAuthProvider.Name)
                {
                    user.GoogleUserId   = authToken.UserId;
                    user.GoogleFullName = authToken.FullName;
                    user.GoogleEmail    = authToken.Email;
                }
                else if (authToken.Provider == YahooOpenIdOAuthProvider.Name)
                {
                    user.YahooUserId   = authToken.UserId;
                    user.YahooFullName = authToken.FullName;
                    user.YahooEmail    = authToken.Email;
                }
            }

            if (AppHost.AppConfig.AdminUserNames.Contains(session.UserAuthName) &&
                !session.HasRole(RoleNames.Admin))
            {
                using (var assignRoles = authService.ResolveService <AssignRolesService>())
                {
                    assignRoles.Post(new AssignRoles {
                        UserName = session.UserAuthName,
                        Roles    = { RoleNames.Admin }
                    });
                }
            }

            //Resolve the DbFactory from the IOC and persist the user info
            using (var db = authService.TryResolve <IDbConnectionFactory>().Open())
                db.Save(user);
        }
        public override void OnAuthenticated(IServiceBase authService, IAuthSession session, IAuthTokens tokens, Dictionary<string, string> authInfo)
        {
            base.OnAuthenticated(authService, session, tokens, authInfo);

            //Populate all matching fields from this session to your own custom User table
            var user = session.ConvertTo<User>();
            user.Id = int.Parse(session.UserAuthId);
            user.GravatarImageUrl64 = !session.Email.IsNullOrEmpty()
                ? CreateGravatarUrl(session.Email, 64)
                : null;

            foreach (var authToken in session.ProviderOAuthAccess)
            {
                if (authToken.Provider == FacebookAuthProvider.Name)
                {
                    user.FacebookName = authToken.DisplayName;
                    user.FacebookFirstName = authToken.FirstName;
                    user.FacebookLastName = authToken.LastName;
                    user.FacebookEmail = authToken.Email;
                }
                else if (authToken.Provider == TwitterAuthProvider.Name)
                {
                    user.TwitterName = user.DisplayName = authToken.UserName;
                }
                else if (authToken.Provider == GoogleOpenIdOAuthProvider.Name)
                {
                    user.GoogleUserId = authToken.UserId;
                    user.GoogleFullName = authToken.FullName;
                    user.GoogleEmail = authToken.Email;
                }
                else if (authToken.Provider == YahooOpenIdOAuthProvider.Name)
                {
                    user.YahooUserId = authToken.UserId;
                    user.YahooFullName = authToken.FullName;
                    user.YahooEmail = authToken.Email;
                }
            }

            if (AppHost.AppConfig.AdminUserNames.Contains(session.UserAuthName)
                && !session.HasRole(RoleNames.Admin))
            {
                using (var assignRoles = authService.ResolveService<AssignRolesService>())
                {
                    assignRoles.Post(new AssignRoles {
                        UserName = session.UserAuthName,
                        Roles = { RoleNames.Admin }
                    });
                }
            }

            //Resolve the DbFactory from the IOC and persist the user info
            using (var db = authService.TryResolve<IDbConnectionFactory>().Open())
                db.Save(user);
        }
Example #6
0
        public override void OnAuthenticated(IServiceBase authService, IAuthSession session, IAuthTokens tokens, Dictionary <string, string> authInfo)
        {
            base.OnAuthenticated(authService, this, tokens, authInfo);
            ILog log = LogManager.GetLogger(GetType());

            log.Info("In OnAuthenticated method");
            //Populate all matching fields from this session to your own custom User table
            var user = session.ConvertTo <User>();

            user.Id     = (session as CustomUserSession).Uid;
            user.Proimg = !session.Email.IsNullOrEmpty()
                ? CreateGravatarUrl(session.Email, 64)
                : null;

            foreach (var authToken in session.ProviderOAuthAccess)
            {
                if (authToken.Provider == FacebookAuthProvider.Name)
                {
                    user.UserName  = authToken.DisplayName;
                    user.FirstName = authToken.FirstName;
                    user.LastName  = authToken.LastName;
                    user.Email     = authToken.Email;
                    //session.bea
                }
                //else if (authToken.Provider == TwitterAuthProvider.Name)
                //{
                //    user.TwitterName = user.DisplayName = authToken.UserName;
                //}
                //else if (authToken.Provider == YahooOpenIdOAuthProvider.Name)
                //{
                //    user.YahooUserId = authToken.UserId;
                //    user.YahooFullName = authToken.FullName;
                //    user.YahooEmail = authToken.Email;
                //}
            }

            //var userAuthRepo = authService.TryResolve<IAuthRepository>();
            //if (AppHost.AppConfig.AdminUserNames.Contains(session.UserAuthName)
            //    && !session.HasRole(RoleNames.Admin, userAuthRepo))
            //{
            //    var userAuth = userAuthRepo.GetUserAuth(session, tokens);
            //    userAuthRepo.AssignRoles(userAuth, roles: new[] { RoleNames.Admin });
            //}

            //Resolve the DbFactory from the IOC and persist the user info
            //using (var db = authService.TryResolve<IDbConnectionFactory>().Open())
            //{
            //    db.Save(user);
            //}
        }
Example #7
0
        static async Task <TUserAuth> LoadOrCreateFromSessionAsync(IAuthSession authSession, Raven.Client.Documents.Session.IAsyncDocumentSession session)
        {
            TUserAuth userAuth;

            if (!authSession.UserAuthId.IsNullOrEmpty())
            {
                var ravenKey = RavenIdConverter.ToString(UserAuthCollectionName, int.Parse(authSession.UserAuthId));
                userAuth = await session.LoadAsync <TUserAuth>(ravenKey);
            }
            else
            {
                userAuth = authSession.ConvertTo <TUserAuth>();
            }
            return(userAuth);
        }
Example #8
0
        /// <summary>
        /// Save the UserAuth from the session.
        /// </summary>
        /// <param name="authSession">The auth session.</param>
        public void SaveUserAuth(IAuthSession authSession)
        {
            var userAuth =
                !string.IsNullOrEmpty(authSession.UserAuthId)
                    ? this.GetUserAuth(authSession.UserAuthId)
                    : authSession.ConvertTo <LightSpeed.UserAuth>();

            if (userAuth.Id == default(int) &&
                !string.IsNullOrEmpty(authSession.UserAuthId))
            {
                userAuth.Id = int.Parse(authSession.UserAuthId);
            }

            this.SaveUserAuth(userAuth);
        }
        public void SaveUserAuth(IAuthSession authSession)
        {
            var userAuth = !authSession.UserAuthId.IsNullOrEmpty()
                ? Session.Load <UserAuthPersistenceDto>(int.Parse(authSession.UserAuthId))
                : authSession.ConvertTo <UserAuth>();

            if (userAuth.Id == default(int) && !authSession.UserAuthId.IsNullOrEmpty())
            {
                userAuth.Id = int.Parse(authSession.UserAuthId);
            }

            userAuth.ModifiedDate = userAuth.ModifiedDate;
            if (userAuth.CreatedDate == default(DateTime))
            {
                userAuth.CreatedDate = userAuth.ModifiedDate;
            }

            Session.Save(new UserAuthPersistenceDto(userAuth));
        }
Example #10
0
        public void SaveUserAuth(IAuthSession authSession)
        {
            var userAuth = !string.IsNullOrEmpty(authSession.UserAuthId)
                ? Session.Load <UserAuthNHibernate>(int.Parse(authSession.UserAuthId))
                : authSession.ConvertTo <UserAuth>();

            if (userAuth.Id == default(int) && !string.IsNullOrEmpty(authSession.UserAuthId))
            {
                userAuth.Id = int.Parse(authSession.UserAuthId);
            }

            userAuth.ModifiedDate = userAuth.ModifiedDate;
            if (userAuth.CreatedDate == default(DateTime))
            {
                userAuth.CreatedDate = userAuth.ModifiedDate;
            }

            Session.Save(new UserAuthNHibernate(userAuth));
        }
Example #11
0
        public async Task SaveUserAuthAsync(IAuthSession authSession, CancellationToken token = default)
        {
            var userAuth = !authSession.UserAuthId.IsNullOrEmpty()
                ? (UserAuth) await GetUserAuthAsync(authSession.UserAuthId, token).ConfigAwait()
                : authSession.ConvertTo <UserAuth>();

            if (userAuth.Id == default && !authSession.UserAuthId.IsNullOrEmpty())
            {
                userAuth.Id = int.Parse(authSession.UserAuthId);
            }

            userAuth.ModifiedDate = DateTime.UtcNow;
            if (userAuth.CreatedDate == default)
            {
                userAuth.CreatedDate = userAuth.ModifiedDate;
            }

            mongoDatabase.GetCollection <UserAuth>(UserAuthCol);
            await SaveUserAsync(userAuth, token).ConfigAwait();
        }
Example #12
0
        public void SaveUserAuth(IAuthSession authSession)
        {
            var userAuth = !authSession.UserAuthId.IsNullOrEmpty()
                ? (UserAuth)GetUserAuth(authSession.UserAuthId)
                : authSession.ConvertTo <UserAuth>();

            if (userAuth.Id == default(int) && !authSession.UserAuthId.IsNullOrEmpty())
            {
                userAuth.Id = int.Parse(authSession.UserAuthId);
            }

            userAuth.ModifiedDate = DateTime.UtcNow;
            if (userAuth.CreatedDate == default(DateTime))
            {
                userAuth.CreatedDate = userAuth.ModifiedDate;
            }

            mongoDatabase.GetCollection <UserAuth>(UserAuthCol);
            SaveUser(userAuth);
        }
        public void SaveUserAuth(IAuthSession authSession)
        {
            dbFactory.Run(db => {
                var userAuth = !authSession.UserAuthId.IsNullOrEmpty()
                    ? db.GetByIdOrDefault <UserAuth>(authSession.UserAuthId)
                    : authSession.ConvertTo <UserAuth>();

                if (userAuth.Id == default(int) && !authSession.UserAuthId.IsNullOrEmpty())
                {
                    userAuth.Id = int.Parse(authSession.UserAuthId);
                }

                userAuth.ModifiedDate = DateTime.UtcNow;
                if (userAuth.CreatedDate == default(DateTime))
                {
                    userAuth.CreatedDate = userAuth.ModifiedDate;
                }

                db.Save(userAuth);
            });
        }
Example #14
0
        public virtual async Task SaveUserAuthAsync(IAuthSession authSession, CancellationToken token = default)
        {
            await using var redis = await factory.GetClientAsync(token).ConfigAwait();

            var userAuth = !authSession.UserAuthId.IsNullOrEmpty()
                ? await GetUserAuthAsync(redis, authSession.UserAuthId, token).ConfigAwait()
                : authSession.ConvertTo <TUserAuth>();

            if (userAuth.Id == default && !authSession.UserAuthId.IsNullOrEmpty())
            {
                userAuth.Id = int.Parse(authSession.UserAuthId);
            }

            userAuth.ModifiedDate = DateTime.UtcNow;
            if (userAuth.CreatedDate == default)
            {
                userAuth.CreatedDate = userAuth.ModifiedDate;
            }

            await redis.StoreAsync(userAuth, token).ConfigAwait();
        }
        public void SaveUserAuth(IAuthSession authSession)
        {
            using (var redis = factory.GetClient())
            {
                var userAuth = !authSession.UserAuthId.IsNullOrEmpty()
                    ? GetUserAuth(redis, authSession.UserAuthId)
                    : authSession.ConvertTo <UserAuth>();

                if (userAuth.Id == default(int) && !authSession.UserAuthId.IsNullOrEmpty())
                {
                    userAuth.Id = int.Parse(authSession.UserAuthId);
                }

                userAuth.ModifiedDate = DateTime.UtcNow;
                if (userAuth.CreatedDate == default(DateTime))
                {
                    userAuth.CreatedDate = userAuth.ModifiedDate;
                }

                redis.Store(userAuth);
            }
        }
Example #16
0
        public async Task SaveUserAuthAsync(IAuthSession authSession, CancellationToken token = default)
        {
            if (authSession == null)
            {
                throw new ArgumentNullException(nameof(authSession));
            }

            var userAuth = !authSession.UserAuthId.IsNullOrEmpty()
                ? await Db.GetItemAsync <TUserAuth>(int.Parse(authSession.UserAuthId), token)
                : authSession.ConvertTo <TUserAuth>();

            if (userAuth.Id == default && !authSession.UserAuthId.IsNullOrEmpty())
            {
                userAuth.Id = int.Parse(authSession.UserAuthId);
            }

            userAuth.ModifiedDate = DateTime.UtcNow;
            if (userAuth.CreatedDate == default)
            {
                userAuth.CreatedDate = userAuth.ModifiedDate;
            }

            await Db.PutItemAsync(Sanitize(userAuth), token : token);
        }
Example #17
0
        public void SaveUserAuth(IAuthSession authSession)
        {
            if (authSession == null)
            {
                throw new ArgumentNullException(nameof(authSession));
            }

            var userAuth = !authSession.UserAuthId.IsNullOrEmpty()
                ? UserAuthRepository.GetById(int.Parse(authSession.UserAuthId))
                : authSession.ConvertTo <JarsUserAuth>();

            if (userAuth.Id == default(int) && !authSession.UserAuthId.IsNullOrEmpty())
            {
                userAuth.Id = int.Parse(authSession.UserAuthId);
            }

            userAuth.ModifiedDate = DateTime.UtcNow;
            if (userAuth.CreatedDate == default(DateTime))
            {
                userAuth.CreatedDate = userAuth.ModifiedDate;
            }

            UserAuthRepository.CreateUpdate(userAuth, MODIEFIED_BY);
        }
Example #18
0
        public async Task SaveUserAuthAsync(IAuthSession authSession, CancellationToken token = default)
        {
            using var session = documentStore.OpenAsyncSession();
            int idInt = int.Parse(authSession.UserAuthId);

            var userAuth = !authSession.UserAuthId.IsNullOrEmpty()
                ? await session.LoadAsync <TUserAuth>(authSession.UserAuthId, token)
                : authSession.ConvertTo <TUserAuth>();

            if (userAuth.Id == default && !authSession.UserAuthId.IsNullOrEmpty())
            {
                userAuth.Id = idInt;
            }

            userAuth.ModifiedDate = DateTime.UtcNow;
            if (userAuth.CreatedDate == default)
            {
                userAuth.CreatedDate = userAuth.ModifiedDate;
            }

            await session.StoreAsync(userAuth, token);

            await session.SaveChangesAsync(token);
        }
        /// <summary>
        /// paso 3
        /// </summary>
        /// <param name="authService"></param>
        /// <param name="session"></param>
        /// <param name="tokens"></param>
        /// <param name="authInfo"></param>
        /// <returns></returns>

        public override IHttpResult OnAuthenticated(IServiceBase authService, IAuthSession session, IAuthTokens tokens, Dictionary <string, string> authInfo)
        {
            //Fill IAuthSession with data you want to retrieve in the app eg:

            var personas = authService.TryResolve <IPersonaGestorConsultas>();

            var persona = personas.Consultar(int.Parse(session.UserAuthId), session.UserAuthName);

            session.LastName    = persona.Apellidos;
            session.FirstName   = persona.Nombres;
            session.Email       = persona.Correo;
            session.DisplayName = persona.Nombres;
            session.ProfileUrl  = persona.Foto;
            session.Roles       = persona.Perfiles.Select(x => x.Nombre).ToList();
            session.Permissions = new List <string>();

            var gestorRegionales = authService.TryResolve <IRegionalGestorConsultas>();

            var gestorColaboradores = authService.TryResolve <IColaboradorGestorConsultas>();



            var user = session.ConvertTo <CustomUserSession>();

            user.PersonaConPerfiles = persona;
            user.Regionales         = gestorRegionales.Consultar().Results;

            user.Colaboradores = gestorColaboradores.Consultar();

            //Call base method to Save Session and fire Auth/Session callbacks:
            return(base.OnAuthenticated(authService, user, tokens, authInfo));

            //Alternatively avoid built-in behavior and explicitly save session with
            //authService.SaveSession(session, SessionExpiry);
            //return null;
        }
        public Task SaveUserAuthAsync(IAuthSession authSession, CancellationToken token = default)
        {
            using var session = documentStore.OpenSession();
            int idInt = int.Parse(authSession.UserAuthId);

            var userAuth = !authSession.UserAuthId.IsNullOrEmpty()
                ? session.Load <TUserAuth>(idInt)
                : authSession.ConvertTo <TUserAuth>();

            if (userAuth.Id == default && !authSession.UserAuthId.IsNullOrEmpty())
            {
                userAuth.Id = idInt;
            }

            userAuth.ModifiedDate = DateTime.UtcNow;
            if (userAuth.CreatedDate == default)
            {
                userAuth.CreatedDate = userAuth.ModifiedDate;
            }

            session.Store(userAuth);
            session.SaveChanges();
            return(TypeConstants.EmptyTask);
        }
        /// <summary>
        /// Save the UserAuth from the session.
        /// </summary>
        /// <param name="authSession">The auth session.</param>
        public void SaveUserAuth(IAuthSession authSession)
        {
            var userAuth =
                !string.IsNullOrEmpty(authSession.UserAuthId)
                    ? this.GetUserAuth(authSession.UserAuthId)
                    : authSession.ConvertTo<LightSpeed.UserAuth>();

            if (userAuth.Id == default(int)
                && !string.IsNullOrEmpty(authSession.UserAuthId))
            {
                userAuth.Id = int.Parse(authSession.UserAuthId);
            }

            this.SaveUserAuth(userAuth);
        }
        public void SaveUserAuth(IAuthSession authSession)
        {
            var userAuth = !authSession.UserAuthId.IsNullOrEmpty()
                ? (UserAuth)GetUserAuth(authSession.UserAuthId)
                : authSession.ConvertTo<UserAuth>();

            if (userAuth.Id == default(int) && !authSession.UserAuthId.IsNullOrEmpty())
                userAuth.Id = int.Parse(authSession.UserAuthId);

            userAuth.ModifiedDate = DateTime.UtcNow;
            if (userAuth.CreatedDate == default(DateTime))
                userAuth.CreatedDate = userAuth.ModifiedDate;

            mongoDatabase.GetCollection<UserAuth>(UserAuthCol);
            SaveUser(userAuth);
        }
		public void SaveUserAuth(IAuthSession authSession)
		{
            using (_session)
			{
				int idInt = int.Parse(authSession.UserAuthId);

				var userAuth = !authSession.UserAuthId.IsNullOrEmpty()
                                   ? _session.Load<UserAuth>(idInt)
                                   : authSession.ConvertTo<UserAuth>();

				if (userAuth.Id == default(int) && !authSession.UserAuthId.IsNullOrEmpty())
					userAuth.Id = idInt;

				userAuth.ModifiedDate = DateTime.UtcNow;
				if (userAuth.CreatedDate == default(DateTime))
					userAuth.CreatedDate = userAuth.ModifiedDate;

                _session.Store(userAuth);
                _session.SaveChanges();
			}
		}
        public void SaveUserAuth(IAuthSession authSession)
        {
            var nhSession = GetCurrentSessionFn(sessionFactory);
            var userAuth = !string.IsNullOrEmpty(authSession.UserAuthId)
                ? nhSession.Load<UserAuthNHibernate>(int.Parse(authSession.UserAuthId))
                : authSession.ConvertTo<UserAuth>();

            if (userAuth.Id == default(int) && !string.IsNullOrEmpty(authSession.UserAuthId))
                userAuth.Id = int.Parse(authSession.UserAuthId);

            userAuth.ModifiedDate = userAuth.ModifiedDate;
            if (userAuth.CreatedDate == default(DateTime))
                userAuth.CreatedDate = userAuth.ModifiedDate;

            nhSession.Save(new UserAuthNHibernate(userAuth));
        }
        public void SaveUserAuth(IAuthSession authSession)
        {
            using (var redis = factory.GetClient())
            {
                var userAuth = !authSession.UserAuthId.IsNullOrEmpty()
                    ? GetUserAuth(redis, authSession.UserAuthId)
                    : authSession.ConvertTo<UserAuth>();

                if (userAuth.Id == default(int) && !authSession.UserAuthId.IsNullOrEmpty())
                    userAuth.Id = int.Parse(authSession.UserAuthId);

                userAuth.ModifiedDate = DateTime.UtcNow;
                if (userAuth.CreatedDate == default(DateTime))
                    userAuth.CreatedDate = userAuth.ModifiedDate;

                redis.Store(userAuth);
            }
        }
        public void SaveUserAuth(IAuthSession authSession)
        {
            using (var db = dbFactory.Open())
            {
                var userAuth = !authSession.UserAuthId.IsNullOrEmpty()
                    ? db.GetByIdOrDefault<UserAuth>(authSession.UserAuthId)
                    : authSession.ConvertTo<UserAuth>();

                if (userAuth.Id == default(int) && !authSession.UserAuthId.IsNullOrEmpty())
                    userAuth.Id = int.Parse(authSession.UserAuthId);

                userAuth.ModifiedDate = DateTime.UtcNow;
                if (userAuth.CreatedDate == default(DateTime))
                    userAuth.CreatedDate = userAuth.ModifiedDate;

                db.Save(userAuth);
            };
        }
        public void SaveUserAuth(IAuthSession authSession)
        {
            var userAuth = !authSession.UserAuthId.IsNullOrEmpty()
                ? Session.Load<UserAuthPersistenceDto>(int.Parse(authSession.UserAuthId))
                : authSession.ConvertTo<UserAuth>();

            if (userAuth.Id == default(int) && !authSession.UserAuthId.IsNullOrEmpty())
                userAuth.Id = int.Parse(authSession.UserAuthId);

            userAuth.ModifiedDate = userAuth.ModifiedDate;
            if (userAuth.CreatedDate == default(DateTime))
                userAuth.CreatedDate = userAuth.ModifiedDate;

            Session.Save(new UserAuthPersistenceDto(userAuth));
        }