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


Python Account.password方法代码示例

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


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

示例1: create_for_email

# 需要导入模块: from models import Account [as 别名]
# 或者: from models.Account import password [as 别名]
 def create_for_email(self, email, commit=False):
     if self.is_email_registered(email): raise EmailAlreadyInUse(email)
     account = Account(email=email)
     account.password = self.hasher.generate()
     db.session.add(account)
     if commit: db.session.commit()
     return account
开发者ID:Bindambc,项目名称:segue,代码行数:9,代码来源:services.py

示例2: callback

# 需要导入模块: from models import Account [as 别名]
# 或者: from models.Account import password [as 别名]
def callback(request):
    error = False
    token = request.session.get('token', None)
    if not token: error = True
        
    token = oauth.OAuthToken.from_string(token)
    if token.key != request.GET.get('oauth_token', 'no-token'): error = True
    token = get_authorized_token(token)

    # Actually login
    obj = is_authorized(token)
    if obj is None: error = True
    
    if error:
        return HttpResponseRedirect('/?msg=2')
    
    username_twitter = obj['screen_name']

    try: # Connexion au compte existant
        u = User.objects.get(username=username_twitter)
        user = Account.objects.get(user=u)
        new_id = u.id
        password_value = user.password
    except User.DoesNotExist: # Creation du compte
        password_value = makePassword(39,40)
        new_user = User.objects.create_user(username=username_twitter, email='[email protected]', password=password_value)
        new_user.first_name = obj['name']
        new_user.is_staff = False
        new_user.is_superuser = False
        new_user.save()
        usermod = new_user
        new_id = new_user.id
        user = Account(user=new_user)
        user.password = password_value
        
    user.oauth_token = token.key
    user.oauth_token_secret = token.secret
    user.url = obj['url']
    user.location = obj['location']
    user.description = obj['description']
    user.avatar_url = obj['profile_image_url']
    user.save()
        
    userco = authenticate(username=username_twitter, password=password_value)

    if userco is not None:
        login(request, userco)
        return HttpResponseRedirect('/?msg=2')
    else:
        return HttpResponseRedirect('/?msg=1')
开发者ID:nephthys,项目名称:shr_im,代码行数:52,代码来源:views.py

示例3: reset_password

# 需要导入模块: from models import Account [as 别名]
# 或者: from models.Account import password [as 别名]
def reset_password():
    if not request.data:
        raise MainException.ACCOUNT_PASSWORD_INVALID

    data = json.loads(request.data)
    code = data.get('code')
    password = data.get('password')

    if code:
        account_obj = Account()
        confirm = account_obj.confirm_email(code, EmailUsageType.DEVELOPER_RESET_PWD)
        # print confirm

        if confirm:
            account_obj.id = confirm['ro_id']
            account_obj.password = password
            account_obj.save(['password'])
            return MainException.OK

    raise MainException.ACCOUNT_INVALID_EMAIL_CODE
开发者ID:jzxyouok,项目名称:kefu_web,代码行数:22,代码来源:api.py

示例4: create

# 需要导入模块: from models import Account [as 别名]
# 或者: from models.Account import password [as 别名]
def create(request):
    if request.method == 'POST':
        # save new account
        name = request.POST['name']
        username = request.POST['username']
        password = request.POST['password']
        email = request.POST['email']

        account = Account()
        account.name = name
        account.username = username
        account.password = password
        account.email = email
        account.perfil = 'N'
        account.save()
      
        return HttpResponseRedirect(reverse('account-login'))
    
    return render_to_response('account/account_create.html',{'request':request},
                              context_instance=RequestContext(request))
开发者ID:PauloDuarte43,项目名称:tomada-social,代码行数:22,代码来源:views.py

示例5: handle_hayhay

# 需要导入模块: from models import Account [as 别名]
# 或者: from models.Account import password [as 别名]
def handle_hayhay(**kwargs):
    description = 'Hayhaytv'
    action = kwargs.get('action', '')
    data = kwargs.get('data', {})

    if action == 'add_account':
        form_data = {
            'email': data['identity'],
            'password': data['password']
        }
        resp = requests.post(login_url, data=form_data)
        resp_data = resp.json()
        if resp_data['object'] == "check_login" and resp_data.get('success', '') == 'success':
            acc = Account()
            acc.site = 'www.hayhaytv.vn'
            acc.identity = data['identity']
            acc.password = data['password']
            db.session.add(acc)
            db.session.commit()
            return jsonify({'ok': True})
        return jsonify({'ok': False})
    elif action == 'login':
        acc = Account.query.filter(Account.site == 'www.hayhaytv.vn').order_by(func.random()).limit(1)
        if acc.all():
            acc = acc.all()[0]
        else:
            return jsonify({'ok': False, 'error': 'No have account'})
        form_data = {
            'email': acc.identity,
            'password': acc.password
        }
        requests.post(login_url, data=form_data, cookies={session_key: str(data['cookies'][session_key])})
        return jsonify({'ok': True})
    elif action == 'get_script_clear_ads':
        return jsonify({
            'ok': True,
            'data': {'url': url_for('static', filename='js/hayhaytv_clear_ads.js', _external=True)}
        })
    elif action == 'get_info':
        return description + ': Login vip, clear ads'
开发者ID:NamPNQ,项目名称:account_vip,代码行数:42,代码来源:hayhaytv.py

示例6: addUser

# 需要导入模块: from models import Account [as 别名]
# 或者: from models.Account import password [as 别名]
def addUser(request):
	'''
	takes in user information and adds it to the database
	upload images as files in your post request
	:param request:
	:return: nothing
	'''
	username = request.POST.get('username', '')
	password = request.POST.get('password', '')
	user = Account()
	user.first_name = request.POST.get('first_name', '')
	user.last_name = request.POST.get('last_name', '')
	user.email = request.POST.get('email', '')
	user.username = username
	user.about_me = request.POST.get('about_me', '')
	user.password = password
	user.profile_image = request.FILES.get('profile')
	user.cover_image = request.FILES.get('cover')
	#create user secret key
	m = hashlib.md5()

	user.friends = json.dumps(request.POST.get('friends', [])) #list of usernames
	user.history = json.dumps(request.POST.get('history', [])) #list of civi's visited
	user.awards = json.dumps(request.POST.get('awards', [])) #list of user awards


	m.update("{username}{password}{int}".format(username=user.username, password=password, int=random.randint(0, sys.maxint)))
	secret_key = m.hexdigest()
	user.secret_key= secret_key
	user.save()
	try:
		user.save()
	except Exception as e:
		return JsonResponse({'result': e})

	return JsonResponse({'status': 200, 'result': user.secret_key})
开发者ID:pscheid2,项目名称:civiwiki.org,代码行数:38,代码来源:views_read.py


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