Beispiel #1
0
        public Session GetSession(string login, string password)
        {
            Player playerOverview = null;

            try
            {
                playerOverview = daoPlayer.Get(login);
            }
            catch (Exception e)
            {
                // Exception caugth from persistenceManager, technical raison, not buiness
                var toRethrow = new InvalidCredentialException(e.Message);
                throw toRethrow;
            }

            // No result found
            if (playerOverview == null)
            {
                throw new InvalidCredentialException(InvalidCredentialEnum.NoLoginFound);
            }

            // Invalid Password
            if (playerOverview.Password != password)
            {
                throw new InvalidCredentialException(InvalidCredentialEnum.BadPassword);
            }

            var session = new Session
            {
                PlayerInBattle = new PlayerInBattle
                {
                    Battle = null,
                    Player = playerOverview
                },
                Id          = Guid.NewGuid().ToString(),
                MaxValidity = DateTime.UtcNow.AddHours(numberOfHourBeforeTimeOut)
            };

            Add(session);
            return(session);
        }
Beispiel #2
0
        public Session GetSession(string login, string password)
        {
            Player playerOverview = null;
            try
            {
                playerOverview = daoPlayer.Get(login);
            }
            catch (Exception e)
            {
                // Exception caugth from persistenceManager, technical raison, not buiness
                var toRethrow = new InvalidCredentialException(e.Message);
                throw toRethrow;
            }

            // No result found
            if (playerOverview == null)
            {
                throw new InvalidCredentialException(InvalidCredentialEnum.NoLoginFound);
            }

            // Invalid Password
            if (playerOverview.Password !=password)
            {
                throw new InvalidCredentialException(InvalidCredentialEnum.BadPassword);
            }

            var session = new Session
            {
                PlayerInBattle = new PlayerInBattle
                {
                    Battle = null,
                    Player = playerOverview
                },
                Id = Guid.NewGuid().ToString(),
                MaxValidity = DateTime.UtcNow.AddHours(numberOfHourBeforeTimeOut)
            };

            Add(session);
            return session;
        }