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


Python User.get_by_username方法代码示例

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


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

示例1: get

# 需要导入模块: from models import User [as 别名]
# 或者: from models.User import get_by_username [as 别名]
	def get(self):
		username = self.request.get('username')
		user = User.get_by_username(username)

		if user is not None:
			userdict = {
				'key': user.key.urlsafe(),
				'username': user.username,
				'email': user.email,
				'first_name': user.first_name,
				'last_name': user.last_name,
				'permissions': json.loads(user.permissions),
				'active': user.active,
				'notes': user.notes,
				'created': tools.datetime_to_str(user.created),
				'organization_creation_allowed': True,
			}
			message = 'Detalles de usuario encontrados.'
			status = 0
		else:
			userdict = {}
			message = 'Detalles de usuario no encontrados.'
			status = 1

	        self.response.headers['Content-Type'] = 'application/json'

		self.response.write(json.dumps({'status': status, 'message': message, 'user': userdict}))
开发者ID:ThomasMarcel,项目名称:ana-tool,代码行数:29,代码来源:user.py

示例2: get_editors

# 需要导入模块: from models import User [as 别名]
# 或者: from models.User import get_by_username [as 别名]
        def get_editors():
            editors = request.form.getlist('editors')
            if editors:
                users = User.get_by_username(editors)
                return users

            return []
开发者ID:Labgoo,项目名称:redshift-goog-datasource,代码行数:9,代码来源:connection_string.py

示例3: login

# 需要导入模块: from models import User [as 别名]
# 或者: from models.User import get_by_username [as 别名]
def login():
    form = LoginForm()
    if form.validate_on_submit():
        user = User.get_by_username(form.username.data)
        login_user(user, form.remember_me.data)
        flash("Logged in Successfully as {}.".format(user.username))
        return redirect(request.args.get('next') or url_for('user', username=user.username))
    return render_template('login.html', form=form)
开发者ID:t-walker,项目名称:flask_tutorial,代码行数:10,代码来源:views.py

示例4: authenticate

# 需要导入模块: from models import User [as 别名]
# 或者: from models.User import get_by_username [as 别名]
 def authenticate(self, username, password):
     try:
         user = User.get_by_username(username)
         if user.check_password(password):
             return user
         else:
             return None
     except User.DoesNotExist:
         return None
开发者ID:savix,项目名称:jnp3,代码行数:11,代码来源:backends.py

示例5: login

# 需要导入模块: from models import User [as 别名]
# 或者: from models.User import get_by_username [as 别名]
def login():
    form = LoginForm()
    if form.validate_on_submit():
        user = User.get_by_username(form.username.data)
        if user is not None and user.check_password(form.password.data):
            login_user(user, form.remember_me.data)
            flash("Logged in successfully as {}.".format(user.username))
            return redirect(request.args.get('next') or url_for('user', username=user.username))
        flash('Incorrect username or password.')
    return render_template("login.html", form=form)
开发者ID:micdoher,项目名称:hold,代码行数:12,代码来源:views.py

示例6: reset_init

# 需要导入模块: from models import User [as 别名]
# 或者: from models.User import get_by_username [as 别名]
def reset_init():
    if request.method == 'POST':
        user = User.get_by_username(request.form['username'])
        if user:
            # add to session to begin the reset flow
            session['reset_id'] = user.id
            return redirect(url_for('reset_question'))
        else:
            flash('User not recognized.')
    return render_template('reset_init.html')
开发者ID:habs3c,项目名称:pwnedhub,代码行数:12,代码来源:views.py

示例7: login

# 需要导入模块: from models import User [as 别名]
# 或者: from models.User import get_by_username [as 别名]
def login():
	form = LoginForm()
	if form.validate_on_submit():
		user = User.get_by_username(form.username.data)
		if user is not None:
			login_user(user, form.remember_me.data)
			flash("Welcome Back %s" % user.username)
			return redirect(request.args.get('next') or url_for('user',username=user.username))
		flash("Incorrect username or password")
	return render_template("login.html",form=form)
开发者ID:ErikCruz,项目名称:thermos,代码行数:12,代码来源:views.py

示例8: login

# 需要导入模块: from models import User [as 别名]
# 或者: from models.User import get_by_username [as 别名]
def login():
    form = LoginForm()
    if form.validate_on_submit():
        user = User.get_by_username(form.username.data)
        if user is not None and user.check_password(form.password.data):
	        login_user(user, form.remember_me.data)
	        return redirect(request.args.get('next') or url_for('user', username=user.username))
	else:
	    flash("Generous Monkey banging QWERTY! OR maybe a bruteforce attempt!")
    return render_template("login.html", form = form)
开发者ID:pombredanne,项目名称:reason,代码行数:12,代码来源:views.py

示例9: login

# 需要导入模块: from models import User [as 别名]
# 或者: from models.User import get_by_username [as 别名]
def login():
    # logic for login
    # confirms username & password combination is in DB before granting access to the rest of the application
    form = LoginForm()
    if form.validate_on_submit():
    	username = request.form['username']
    	password = request.form['password']
    	user = User.get_by_username(username)
    	if user is not None:
    		if user.password == password:
    			login_user(user)
    			return redirect(request.args.get("next") or url_for('index'))
    	else: 
    		flash('Incorrect Username/Password Combination')
    return render_template('login.html', form=form)
开发者ID:ImNitinNayar7,项目名称:json-in-db,代码行数:17,代码来源:views.py

示例10: login

# 需要导入模块: from models import User [as 别名]
# 或者: from models.User import get_by_username [as 别名]
def login():
    form = LoginForm()
    if form.validate_on_submit():
        user = User.get_by_username(form.username.data)

        if not user:
            flash('That didn\'t work :(. Never seen you before.')
            return render_template('login.html', form=form)

        if user.check_password(form.password.data, request) == False:
            flash('That didn\'t work :(. Check yo self.')
            return render_template('login.html', form=form)

        login_user(user)
        flash("Logged in successfully.")
        return redirect(request.args.get("next") or url_for("home"))

    return render_template("login.html", form=form)
开发者ID:nickhs,项目名称:vowel,代码行数:20,代码来源:user.py

示例11: cadastrar

# 需要导入模块: from models import User [as 别名]
# 或者: from models.User import get_by_username [as 别名]
def cadastrar(_handler, _resp, name, username, email, passwd):
    errors = []
    if User.get_by_username(username):
        errors.append('username_error')

    if "@" not in email or "." not in email:
        errors.append('invalid_email')

    if len(passwd) < 6:
        errors.append('invalid_pw')

    if errors:
        url = router.to_path(site_index) + "?errors=" + "+".join(errors)
        _handler.redirect(url)
        return

    u = User(name=name, username=username.strip(), email=email, passwd=passwd)
    u.put()
    
    #to avoid eventually consistency
    time.sleep(0.5)

    logar(_handler, _resp, username, passwd)
开发者ID:giovaneliberato,项目名称:keepfamily,代码行数:25,代码来源:usuario.py

示例12: get_editors

# 需要导入模块: from models import User [as 别名]
# 或者: from models.User import get_by_username [as 别名]
 def get_editors():
     editors = request.form.get('editors', '').split(',')
     return User.get_by_username(editors)
开发者ID:melpon,项目名称:redshift-goog-datasource,代码行数:5,代码来源:connection_string.py

示例13: initialize

# 需要导入模块: from models import User [as 别名]
# 或者: from models.User import get_by_username [as 别名]
 def initialize(self, *a, **kw):
     webapp2.RequestHandler.initialize(self, *a, **kw)
     username = self.read_cookie('username')
     if username and len(username) == 0:
         username = None
     self.user = username and User.get_by_username(username)
开发者ID:mataelle,项目名称:multiuser-blog,代码行数:8,代码来源:main.py

示例14: leader

# 需要导入模块: from models import User [as 别名]
# 或者: from models.User import get_by_username [as 别名]
 def leader(self):
   return User.get_by_username(self.activity.owner)
开发者ID:paulftw,项目名称:utsoac,代码行数:4,代码来源:handlers.py


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