Exemplo n.º 1
0
        /// <summary>
        /// Tries to log in with the corresponding method of  
        /// <c>UserService</c>, and if successful, inserts in the
        /// session the necessary objects for an authenticated user.
        /// </summary>
        /// <param name="context">Http Context includes request, response, etc.</param>
        /// <param name="loginName">Username</param>
        /// <param name="password">User Password</param>
        /// <param name="passwordIsEncrypted">Password is either encrypted or 
        /// in clear text</param>
        /// <param name="rememberMyPassword">Remember password to the next 
        /// logins</param>
        /// <exception cref="IncorrectPasswordException"/>
        /// <exception cref="InstanceNotFoundException"/>
        ///<exception cref="InternalErrorException"/>
        private static LoginResult DoLogin(HttpContext context,
            String loginName, String password, Boolean passwordIsEncrypted,
            Boolean rememberMyPassword)
        {
            LoginResult loginResult =
                userService.Login(loginName, password,
                    passwordIsEncrypted);

            /* Insert necessary objects in the session. */

            UserSession userSession = new UserSession();
            userSession.UserProfileId = loginResult.UserId;
            userSession.FirstName = loginResult.Name;

            Locale locale =
                new Locale(loginResult.Language, loginResult.Country);

            UpdateSessionForAuthenticatedUser(context, userSession, locale);

            return loginResult;
        }
Exemplo n.º 2
0
 /// <summary>
 /// Updates the session values for an previously authenticated user
 /// </summary>
 /// <param name="context">Http Context includes request, response, etc.</param>
 /// <param name="userSession">The user data stored in session.</param>
 /// <param name="locale">The locale info.</param>
 private static void UpdateSessionForAuthenticatedUser(
     HttpContext context, UserSession userSession, Locale locale)
 {
     /* Insert objects in session. */
     context.Session.Add(USER_SESSION_ATTRIBUTE, userSession);
     context.Session.Add(LOCALE_SESSION_ATTRIBUTE, locale);
 }
Exemplo n.º 3
0
        /// <summary>
        /// Registers the user.
        /// </summary>
        /// <param name="context">Http Context includes request, response, etc.</param>
        /// <param name="loginName">Username</param>
        /// <param name="clearPassword">Password in clear text</param>
        /// <param name="UserDetails">The user profile details.</param>
        /// <exception cref="DuplicateInstanceException"/>
        public static void RegisterUser(HttpContext context,
            String loginName, String clearPassword,
            UserDetails userDetails)
        {
            /* Register user. */
            Es.Udc.DotNet.Betbook.Model.User user = userService.RegisterUser(loginName, clearPassword, userDetails);

            /* Insert necessary objects in the session. */
            UserSession userSession = new UserSession();
            userSession.UserProfileId = user.userId;
            userSession.FirstName = userDetails.Name;

            Locale locale = new Locale(userDetails.Language, userDetails.Country);

            UpdateSessionForAuthenticatedUser(context, userSession, locale);

            FormsAuthentication.SetAuthCookie(loginName, false);
        }