当前位置: 首页>>代码示例>>Python>>正文


Python User.add_new_user方法代码示例

本文整理汇总了Python中model.User.add_new_user方法的典型用法代码示例。如果您正苦于以下问题:Python User.add_new_user方法的具体用法?Python User.add_new_user怎么用?Python User.add_new_user使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在model.User的用法示例。


在下文中一共展示了User.add_new_user方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: process_login

# 需要导入模块: from model import User [as 别名]
# 或者: from model.User import add_new_user [as 别名]
def process_login():
    """Look up user and store user in session"""

    email_input = request.form.get("email")
    password_input = request.form.get("password")

    user = User.query.filter_by(email=email_input).first()
    print "USER HERE:", user
    if user is None:
        flash("Welcome to Ratings!")
        new_user = User.add_new_user(email=email_input, password=password_input)
        session['logged_in_user'] = new_user.user_id
        return redirect("/users/" + str(new_user.user_id))
    else:
        if password_input != user.password:
            flash("Incorrect password, try again")
            return redirect("/login")
        else:
            flash("Login successful")
            session['logged_in_user'] = user.user_id
            return redirect("/users/" + str(user.user_id))
开发者ID:jessanettica,项目名称:HB-Ratings-Project,代码行数:23,代码来源:server.py

示例2: process_login

# 需要导入模块: from model import User [as 别名]
# 或者: from model.User import add_new_user [as 别名]
def process_login():
	"""Log user into siteself.
	Find the user's login credentials located in the 'request.form'
	dictionary, look up the user, and store them in the session.
	"""
	email_input = request.form.get("email")
	pword_input = request.form.get("password")
	
	user = User.query.filter_by(email=email_input).first()
	print "******************", user
	if user is None:
		flash("Welcome new user!")
		new_user = User.add_new_user(email=email_input, password=pword_input)
		session['logged_in_user'] = new_user.user_id
		return redirect("/users/" + str(new_user.user_id))
	else:
		if pword_input != user.password:
			flash("Incorrect password, try again")
			return redirect("/login")
		else:
			flash("Login successful!!")
			session['logged_in_user'] = user.user_id
			return redirect("/users/" + str(user.user_id))
开发者ID:ammeurer,项目名称:ratings,代码行数:25,代码来源:server.py

示例3: post

# 需要导入模块: from model import User [as 别名]
# 或者: from model.User import add_new_user [as 别名]
    def post(self):
        try:
            name = self.get_argument("name")
            password = self.get_argument("password")
        except:
            self.redirect('%s/admin/login'% BASE_URL)
            return

        if name and password:
            has_user = User.check_has_user()
            if has_user:
                #check user
                password = md5(password.encode('utf-8')).hexdigest()
                user = User.check_user( name, password)
                if user:
                    #logging.error('user ok')
                    self.set_cookie('username', name, path="/", expires_days = 365 )
                    self.set_cookie('userpw', password, path="/", expires_days = 365 )
                    self.redirect('%s/admin/'% BASE_URL)
                    return
                else:
                    #logging.error('user not ok')
                    self.redirect('%s/admin/login'% BASE_URL)
                    return
            else:
                #add new user
                newuser = User.add_new_user( name, password)
                if newuser:
                    self.set_cookie('username', name, path="/", expires_days = 365 )
                    self.set_cookie('userpw', md5(password.encode('utf-8')).hexdigest(), path="/", expires_days = 365 )
                    self.redirect('%s/admin/'% BASE_URL)
                    return
                else:
                    self.redirect('%s/admin/login'% BASE_URL)
                    return
        else:
            self.redirect('%s/admin/login'% BASE_URL)
开发者ID:cylinderlee,项目名称:saepy-log,代码行数:39,代码来源:admin.py


注:本文中的model.User.add_new_user方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。