Beispiel #1
0
        /// <summary>
        /// The activate.
        /// </summary>
        /// <param name="activationCode">
        /// The activation code.
        /// </param>
        /// <returns>
        /// The <see cref="string"/>.
        /// </returns>
        public string Activate(string activationCode)
        {
            var arr = UserActivationModel.GetOneByCode(activationCode).Value;

            if (arr == null)
            {
                var error = new Error(
                    Errors.CODE_ERRORTYPE_USER_INACTIVE,
                    ErrorsTexts.UserActivationError_Subject,
                    ErrorsTexts.UserActivationError_InvalidActivationCode);
                this.LogError("Rest.Activate", error);
                throw new FaultException <Error>(error, error.errorMessage);
            }

            if (arr.DateExpires < DateTime.Now)
            {
                var error = new Error(
                    Errors.CODE_ERRORTYPE_USER_INACTIVE,
                    ErrorsTexts.UserActivationError_Subject,
                    ErrorsTexts.UserActivationError_InvalidActivationCode);
                this.LogError("Rest.Activate", error);
                throw new FaultException <Error>(error, error.errorMessage);
            }

            var user = arr.User;

            user.Status       = UserStatus.Active;
            user.DateModified = DateTime.Now;
            UserActivationModel model = this.UserActivationModel;
            UserActivation      userActivation;

            if ((userActivation = model.GetLatestByUser(user.Id).Value) == null)
            {
                userActivation = UserActivation.Build(user);
                model.RegisterSave(userActivation);
            }

            UserModel.RegisterSave(user);
            //IoC.Resolve<RealTimeNotificationModel>()
            //    .NotifyClientsAboutChangesInTable<User>(NotificationType.Update, user.Company.Id, user.Id);
            UserActivationModel.RegisterDelete(arr);
            this.SendActivationLinkEmail(user.FirstName, user.Email, userActivation.ActivationCode);
            if (WebOperationContext.Current != null)
            {
                var response = WebOperationContext.Current.OutgoingResponse;
                response.StatusCode = HttpStatusCode.Redirect;
                response.Headers.Add(HttpResponseHeader.Location, (string)this.Settings.BasePath);
            }

            return(null);
        }
Beispiel #2
0
        public virtual ActionResult Activate(string code)
        {
            var passwordActivation = _userActivationModel.GetOneByCode(code).Value;
            var contact            = passwordActivation.With(x => x.User);

            if (contact != null)
            {
                contact.Status = UserStatus.Activating;
                _userModel.RegisterSave(contact, true);
                return(RedirectToAction(EdugameCloudT4.Home.Admin("activate", code)));
            }

            return(RedirectToAction(EdugameCloudT4.Home.Admin()));
        }