コード例 #1
0
ファイル: login.py プロジェクト: rranshous/manythanksfrom.us
    def set(self, username, password):
        """
        accepts form vars for username and password
        if all is well sets session info for ur login
        """

        # if there are no args, give them the form
        if not username and not password:
            return render("/login_form.html")

        # get the user by the username
        user_data = o.User.get_data(key=username)

        # no user data?
        if not user_data:
            add_flash("error", "User not found")
            return render("/login_form.html")

        # check their password
        if not o.User.check_password(user_data, password):
            add_flash("error", "Incorrect password")
            return render("/login_form.html")

        # set them as active user
        set_active_user(user_data.get("_hash"))
コード例 #2
0
ファイル: login.py プロジェクト: rranshous/manythanksfrom.us
    def set(self, username, password):
        """
        accepts form vars for username and password
        if all is well sets session info for ur login
        """

        # if there are no args, give them the form
        if not username and not password:
            return render('/login_form.html')

        # get the user by the username
        user_data = o.User.get_data(key=username)

        # no user data?
        if not user_data:
            add_flash('error', 'User not found')
            return render('/login_form.html')

        # check their password
        if not o.User.check_password(user_data, password):
            add_flash('error', 'Incorrect password')
            return render('/login_form.html')

        # set them as active user
        set_active_user(user_data.get('_hash'))
コード例 #3
0
ファイル: admin.py プロジェクト: rranshous/manythanksfrom.us
    def index(self):
        # return back the admin home page

        # for now set the user to me
        set_active_user('237823077639407214003259210226144395600')

        # get our user's data
        user_data = get_active_user_data()

        cherrypy.log('active_user: %s %s' %
                     (cherrypy.session.get('user_hash'),user_data))

        # we need to get the user's events
        event_datas = o.Event.get_relatives_data(user_data)
        return render('/admin/home.html',
                      event_datas=event_datas)
コード例 #4
0
ファイル: login.py プロジェクト: rranshous/manythanksfrom.us
    def create(self, username=None, password=None):
        """
        creates a new login, usernames must be unique
        """

        # if there are no args, return the form
        if not username and not password:
            return render("/login_form.html")

        # check and make sure they provided a username
        if not username:
            add_flash("error", "Must provide username")
            return render("/create_login_form.html")

        # check the password
        if not password:
            add_flash("error", "Must provide password")
            return render("/create_login_form.html")

        # figure out what the hash would be for the usernaem
        _hash = o.User._get_hash({"username": username})

        # see if there is already a user w/ the username
        user_data = o.User.get_data(_hash)

        # wwops, already exists
        if user_data:
            add_flash("error", "User already exists")
            return render("/create_login_form.html")

        # now that we know it's unique, create the user
        user_data = o.User.get_data()

        # set the username and password
        user_data["username"] = username
        user_data["password"] = password

        # push our data out
        o.User.set_data(user_data)

        # set the new user as the active user
        set_active_user(user_data.get("_hash"))

        # now return them to their admin page
        redirect("/admin")
コード例 #5
0
ファイル: login.py プロジェクト: rranshous/manythanksfrom.us
    def create(self, username=None, password=None):
        """
        creates a new login, usernames must be unique
        """

        # if there are no args, return the form
        if not username and not password:
            return render('/login_form.html')

        # check and make sure they provided a username
        if not username:
            add_flash('error', 'Must provide username')
            return render('/create_login_form.html')

        # check the password
        if not password:
            add_flash('error', 'Must provide password')
            return render('/create_login_form.html')

        # figure out what the hash would be for the usernaem
        _hash = o.User._get_hash({'username': username})

        # see if there is already a user w/ the username
        user_data = o.User.get_data(_hash)

        # wwops, already exists
        if user_data:
            add_flash('error', 'User already exists')
            return render('/create_login_form.html')

        # now that we know it's unique, create the user
        user_data = o.User.get_data()

        # set the username and password
        user_data['username'] = username
        user_data['password'] = password

        # push our data out
        o.User.set_data(user_data)

        # set the new user as the active user
        set_active_user(user_data.get('_hash'))

        # now return them to their admin page
        redirect('/admin')