示例#1
0
文件: login.py 项目: sylvestre/indico
    def _process(self):
        self._disableCaching()
        #Check for automatic login
        auth = AuthenticatorMgr()
        av = auth.autoLogin(self)
        if av:
            url = self._returnURL
            tzUtil = timezoneUtils.SessionTZ(av)
            tz = tzUtil.getSessionTZ()
            self._getSession().setVar("ActiveTimezone", tz)
            self._getSession().setUser(av)
            if Config.getInstance().getBaseSecureURL().startswith('https://'):
                url = str(url).replace('http://', 'https://')
            self._redirect(url, noCache=True)
        if not self._signIn:
            p = signIn.WPSignIn(self)
            return p.display(returnURL=self._returnURL)
        else:
            li = LoginInfo(self._login, self._password)
            av = auth.getAvatar(li)
            if not av:
                p = signIn.WPSignIn(self,
                                    login=self._login,
                                    msg=_("Wrong login or password"))
                return p.display(returnURL=self._returnURL)
            elif not av.isActivated():
                if av.isDisabled():
                    self._redirect(urlHandlers.UHDisabledAccount.getURL(av))
                else:
                    self._redirect(urlHandlers.UHUnactivatedAccount.getURL(av))
                return _(
                    "your account is not activate\nPlease active it and retry")
            else:
                url = self._returnURL
                #raise(str(dir(av)))
                self._getSession().setUser(av)
                tzUtil = timezoneUtils.SessionTZ(av)
                tz = tzUtil.getSessionTZ()
                self._getSession().setVar("ActiveTimezone", tz)

            if self._userId != "":
                if "?" in url:
                    url += "&userId=%s" % self._userId
                else:
                    url += "?userId=%s" % self._userId
            if Config.getInstance().getBaseSecureURL().startswith('https://'):
                url = str(url).replace('http://', 'https://')
            self._redirect(url, noCache=True)
示例#2
0
 def _process(self):
     if self._av:
         tzUtil = timezoneUtils.SessionTZ(self._av)
         tz = tzUtil.getSessionTZ()
         self._getSession().setVar("ActiveTimezone", tz)
         self._getSession().setUser(self._av)
         self._redirect(self._returnURL)
     else:
         p = adminPages.WPSelectUserToLogAs(self)
         return p.display(**self._getRequestParams())
示例#3
0
 def _getAnswer(self):
     # We don't overwrite a previous entry - the original (admin) user should be kept there
     session.setdefault('login_as_orig_user', {
         'timezone': session.timezone,
         'user_id': session.user.id,
         'user_name': session.user.get_full_name(last_name_first=False, last_name_upper=False)
     })
     session.user = self._user
     session.timezone = timezoneUtils.SessionTZ(self._user.as_avatar).getSessionTZ()
     return True
示例#4
0
 def _getAnswer(self):
     tzUtil = timezoneUtils.SessionTZ(self._av)
     tz = tzUtil.getSessionTZ()
     # We don't overwrite a previous entry - the original (admin) user should be kept there
     session.setdefault('login_as_orig_user', {
         'timezone': session.timezone,
         'user_id': session.user.getId(),
         'user_name': session.user.getStraightAbrName()
     })
     session.user = self._av
     session.timezone = tz
     return True
示例#5
0
 def _getAnswer(self):
     # We don't overwrite a previous entry - the original (admin) user should be kept there
     session.setdefault(
         'login_as_orig_user', {
             'session_data': {
                 k: session.pop(k)
                 for k in session.keys()
                 if k[0] != '_' or k in {'_timezone', '_lang'}
             },
             'user_id':
             session.user.id,
             'user_name':
             session.user.get_full_name(last_name_first=False,
                                        last_name_upper=False)
         })
     session.user = self._user
     session.lang = session.user.settings.get('lang')
     session.timezone = timezoneUtils.SessionTZ(
         self._user.as_avatar).getSessionTZ()
     return True
示例#6
0
 def _getAnswer(self):
     tzUtil = timezoneUtils.SessionTZ(self._av)
     tz = tzUtil.getSessionTZ()
     self._getSession().setVar("ActiveTimezone", tz)
     self._getSession().setUser(self._av)
     return True
示例#7
0
    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()
        """