コード例 #1
0
ファイル: users.py プロジェクト: arturodr/indico
 def _process(self):
     self._avatar.activateAccount()
     #----Grant rights if anything
     ph = pendingQueues.PendingQueuesHolder()
     ph.grantRights(self._avatar)
     #-----
     minfo = info.HelperMaKaCInfo.getMaKaCInfoInstance()
     if minfo.getModerateAccountCreation():
         mail.sendAccountActivated(self._avatar).send()
     self._redirect(urlHandlers.UHUserDetails.getURL(self._avatar))
コード例 #2
0
ファイル: login.py プロジェクト: lukasnellen/indico
    def _process(self):

        av = AvatarHolder().getById(self._userId)
        if av.isActivated():
            p = signIn.WPAccountAlreadyActivated(self, av)
            return p.display()
            #return "your account is already activated"
        if av.isDisabled():
            p = signIn.WPAccountDisabled(self, av)
            return p.display()
            #return "your account is disabled. please, ask to enable it"
        elif self._key == av.getKey():
            av.activateAccount()
            #----Grant any kind of rights if anything
            ph = pendingQueues.PendingQueuesHolder()
            ph.grantRights(av)
            #-----
            p = signIn.WPAccountActivated(self, av)
            return p.display()
            #return "Your account is activate now"
        else:
            return "Wrong key. Please, ask for a new one"
            pass
コード例 #3
0
ファイル: users.py プロジェクト: arturodr/indico
 def _process(self):
     save = False
     ih = AuthenticatorMgr()
     minfo = info.HelperMaKaCInfo.getMaKaCInfoInstance()
     self._params["msg"] = ""
     if self._save:
         save = True
         #check submited data
         if not self._params.get("name", ""):
             self._params["msg"] += _("You must enter a name.") + "<br>"
             save = False
         if not self._params.get("surName", ""):
             self._params["msg"] += _("You must enter a surname.") + "<br>"
             save = False
         if not self._params.get("organisation", ""):
             self._params["msg"] += _(
                 "You must enter the name of your organisation.") + "<br>"
             save = False
         if not self._params.get("email", ""):
             self._params["msg"] += _(
                 "You must enter an email address.") + "<br>"
             save = False
         if not self._params.get("login", ""):
             self._params["msg"] += _("You must enter a login.") + "<br>"
             save = False
         if not self._params.get("password", ""):
             self._params["msg"] += _(
                 "You must define a password.") + "<br>"
             save = False
         if self._params.get("password", "") != self._params.get(
                 "passwordBis", ""):
             self._params["msg"] += _(
                 "You must enter the same password twice.") + "<br>"
             save = False
         if not ih.isLoginFree(self._params.get("login", "")):
             self._params["msg"] += _(
                 "Sorry, the login you requested is already in use. Please choose another one."
             ) + "<br>"
             save = False
         if not self._validMail(self._params.get("email", "")):
             self._params["msg"] += _(
                 "You must enter a valid email address")
             save = False
     if save:
         #Data are OK, Now check if there is an existing user or create a new one
         ah = user.AvatarHolder()
         res = ah.match({"email": self._params["email"]},
                        exact=1,
                        forceWithoutExtAuth=True)
         if res:
             #we find a user with the same email
             a = res[0]
             #check if the user have an identity:
             if a.getIdentityList():
                 self._redirect(
                     urlHandlers.UHUserExistWithIdentity.getURL(a))
                 return
             else:
                 #create the identity to the user and send the comfirmatio email
                 _UserUtils.setUserData(a, self._params)
                 li = user.LoginInfo(self._params["login"],
                                     self._params["password"])
                 id = ih.createIdentity(li, a, "Local")
                 ih.add(id)
                 DBMgr.getInstance().commit()
                 if minfo.getModerateAccountCreation():
                     mail.sendAccountCreationModeration(a).send()
                 else:
                     mail.sendConfirmationRequest(a).send()
                     if minfo.getNotifyAccountCreation():
                         mail.sendAccountCreationNotification(a).send()
         else:
             a = user.Avatar()
             _UserUtils.setUserData(a, self._params)
             ah.add(a)
             li = user.LoginInfo(self._params["login"],
                                 self._params["password"])
             id = ih.createIdentity(li, a, "Local")
             ih.add(id)
             DBMgr.getInstance().commit()
             if minfo.getModerateAccountCreation():
                 mail.sendAccountCreationModeration(a).send()
             else:
                 mail.sendConfirmationRequest(a).send()
                 if minfo.getNotifyAccountCreation():
                     mail.sendAccountCreationNotification(a).send()
         self._redirect(urlHandlers.UHUserCreated.getURL(a))
     else:
         cp = None
         if self._params.has_key("cpEmail"):
             ph = pendingQueues.PendingQueuesHolder()
             cp = ph.getFirstPending(self._params["cpEmail"])
         if self._aw.getUser() and self._aw.getUser() in minfo.getAdminList(
         ).getList():
             p = adminPages.WPUserCreation(self, self._params, cp)
         else:
             p = adminPages.WPUserCreationNonAdmin(self, self._params, cp)
         return p.display()
コード例 #4
0
ファイル: users.py プロジェクト: lukasnellen/indico
    def _process(self):
        if self._cancel:
            self._redirect(urlHandlers.UHUserDetails.getURL(self._avatar))
            return
        save = False
        self._params["msg"] = ""
        if self._save:
            save = True
            #check submited data
            if not self._params.get("name", ""):
                self._params["msg"] += "You must enter a name.<br>"
                save = False
            if not self._params.get("surName", ""):
                self._params["msg"] += "You must enter a surname.<br>"
                save = False
            if not self._params.get("organisation", ""):
                self._params[
                    "msg"] += "You must enter the name of your organisation.<br>"
                save = False
            if not self._params.get("email", ""):
                self._params["msg"] += "You must enter an email address.<br>"
                save = False
        if self._params.get("email", "") != self._avatar.getEmail():
            av = user.AvatarHolder().match(
                {"email": self._params.get("email", "")},
                forceWithoutExtAuth=True)
            if av:
                if av[0] != self._avatar:
                    self._params["msg"] += "This email is already used"
                    save = False
        if save:
            #Data are OK, save them
            idxs = indexes.IndexesHolder()
            org = idxs.getById('organisation')
            email = idxs.getById('email')
            name = idxs.getById('name')
            surName = idxs.getById('surName')
            org.unindexUser(self._avatar)
            email.unindexUser(self._avatar)
            name.unindexUser(self._avatar)
            surName.unindexUser(self._avatar)
            self._params["secEmails"] = self._normaliseListParam(
                self._params.get("secEmails", []))
            _UserUtils.setUserData(self._avatar, self._params)
            self._getSession().setLang(self._avatar.getLang())
            org.indexUser(self._avatar)
            email.indexUser(self._avatar)
            name.indexUser(self._avatar)
            surName.indexUser(self._avatar)

            #----Grant rights if anything
            ph = pendingQueues.PendingQueuesHolder()
            ph.grantRights(self._avatar)
            #-----
            websession = self._aw.getSession()
            tzUtil = timezoneUtils.SessionTZ(self._aw.getUser())
            tz = tzUtil.getSessionTZ()
            websession.setVar("ActiveTimezone", tz)
            self._redirect(urlHandlers.UHUserDetails.getURL(self._avatar))

        elif self._addEmail:
            self._params["secEmails"] = self._normaliseListParam(
                self._params.get("secEmails", []))
            email = self._params.get("secEmailAdd", "")
            av = user.AvatarHolder().match({"email": email},
                                           exact=1,
                                           forceWithoutExtAuth=True)
            add = True
            if av:
                if av[0] != self._avatar:
                    self._params["msg"] += "This email is already used"
                    add = False
            if email and add and not email in self._params["secEmails"]:
                self._params["secEmails"].append(email)
            p = adminPages.WPUserModification(self, self._avatar, self._params)
            return p.display()
        elif self._removeEmail:

            emails = self._normaliseListParam(
                self._params.get("secEmailRemove", []))
            self._params["secEmails"] = self._normaliseListParam(
                self._params["secEmails"])
            for email in emails:
                if email and email in self._params["secEmails"]:
                    self._params["secEmails"].remove(email)
            p = adminPages.WPUserModification(self, self._avatar, self._params)
            websession = self._aw.getSession()
            tzUtil = timezoneUtils.SessionTZ(self._aw.getUser())
            tz = tzUtil.getSessionTZ()
            websession.setVar("ActiveTimezone", tz)
            return p.display()
        else:
            p = adminPages.WPUserModification(self, self._avatar, self._params)
            websession = self._aw.getSession()
            tzUtil = timezoneUtils.SessionTZ(self._aw.getUser())
            tz = tzUtil.getSessionTZ()
            websession.setVar("ActiveTimezone", tz)
            return p.display()
        """