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


Python User.create_user方法代码示例

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


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

示例1: register

# 需要导入模块: from models import User [as 别名]
# 或者: from models.User import create_user [as 别名]
def register():
    form = SignUpForm()
    if form.validate_on_submit():
        User.create_user(form.email.data, form.password.data)
        return redirect(url_for("index"))

    return render_template("register.html", form=form)
开发者ID:guillaumemaka,项目名称:tacocat_treehouse_challenge,代码行数:9,代码来源:tacocat.py

示例2: create_users

# 需要导入模块: from models import User [as 别名]
# 或者: from models.User import create_user [as 别名]
 def create_users(count=2):
     for i in range(count):
         User.create_user(
             username='test{}'.format(i),
             email='test{}@email.com'.format(i),
             password='password {}'.format(i)
         )
开发者ID:diawest82,项目名称:angular-todo_v3,代码行数:9,代码来源:test.py

示例3: test_create_duplicate_user

# 需要导入模块: from models import User [as 别名]
# 或者: from models.User import create_user [as 别名]
 def test_create_duplicate_user(self):
     with test_database(TEST_DB, (User,)):
         self.create_users()
         with self.assertRaises(ValueError):
             User.create_user(
                 email='[email protected]',
                 password='password'
             )
开发者ID:BobKingstone,项目名称:tacocat,代码行数:10,代码来源:app_tests.py

示例4: post

# 需要导入模块: from models import User [as 别名]
# 或者: from models.User import create_user [as 别名]
  def post(self):
    """Registers the user and updates datastore"""
    first_name = cgi.escape(self.request.get('first_name')).strip()
    last_name = cgi.escape(self.request.get('last_name')).strip()
    username = cgi.escape(self.request.get('username')).strip().lower()
    email = cgi.escape(self.request.get('email')).strip().lower()
    password = cgi.escape(self.request.get('password'))
    account = cgi.escape(self.request.get('account_type'))
    unique_properties = ['email_address']
    lower_first = first_name.lower()
    lower_last = last_name.lower()


    # Initial Creation of User      
    user_data = User.create_user(username,
    unique_properties, username=username,
    email_address=email, first_name=first_name, lower_first_name=lower_first, 
    password_raw=password,
    last_name=last_name, lower_last_name = lower_last, 
    subscriptions=["news", "techeria"], 
    account_type=account,
    verified=False)
    # TODO: Look for new wait method
    time.sleep(1)
    try:
      u = self.auth.get_user_by_password(username, password, remember=True,
      save_session=True)
      self.redirect('/profile/{}'.format(self.user_model.username))
    except( auth.InvalidAuthIdError, auth.InvalidPasswordError):
      error = "Invalid Email/Password"
      self.response.out.write(template.render('views/login.html', {'error':error}))
开发者ID:cthavy,项目名称:Ninja-Frontend,代码行数:33,代码来源:Authentication.py

示例5: post

# 需要导入模块: from models import User [as 别名]
# 或者: from models.User import create_user [as 别名]
  def post(self):
    """Registers the user and updates datastore"""
    username = cgi.escape(self.request.get('username')).strip().lower()
    email = cgi.escape(self.request.get('email')).strip().lower()
    password = cgi.escape(self.request.get('password'))
    first_name = cgi.escape(self.request.get('first_name')).strip()
    last_name = cgi.escape(self.request.get('last_name')).strip()
    l_first_name = first_name.lower()
    l_last_name = last_name.lower()
    telephone = "+1" + cgi.escape(self.request.get('telephone')).strip()
    avatar= self.request.get('img')
    avatar = images.resize(avatar,400,400) 
    
    unique_properties = ['email_address']

    # Creation of User
    user_data = User.create_user(username, unique_properties, username=username,
                                email_address=email, password_raw=password, first_name = first_name,
                                last_name=last_name, l_first_name = l_first_name, l_last_name = l_last_name,
                                telephone = telephone, avatar = avatar, verified=False)
    time.sleep(1)
    try:
      u = self.auth.get_user_by_password(username, password, remember=True,
      save_session=True)
      self.redirect('/feed')
    except( auth.InvalidAuthIdError, auth.InvalidPasswordError):
      error = "Invalid Email/Password"
      self.response.out.write(template.render('views/login.html', {'error':error}))
开发者ID:Qiwis,项目名称:foodie,代码行数:30,代码来源:account_creation.py

示例6: user_from_info

# 需要导入模块: from models import User [as 别名]
# 或者: from models.User import create_user [as 别名]
    def user_from_info(self, info):
        """Get or create a user from the oauth providers info.
        
        * info: dict in the form::
        
            {
                'first_name': fname,
                'last_name': lname,
                'location': info.get('location', "Pythonville, USA"),
                'description': info.get('description', ''),
                'url': info.get('url'),
                'picture_url': info.get('picture', ''),
                # Default username
                'username': info['username'],
                'auth_id': 'twitter:username'
            }
        """
        auth_id = info.pop('auth_id')
        username = info.pop('username')
        user = User.get_by_auth_id(auth_id)

        if user is None:
            created, user = User.create_user(auth_id, **info)
            if not created:
                raise Exception('Auth ID is not unique %s' % auth_id)
            
            user.add_username(username)

        return user
开发者ID:antio,项目名称:gae_django,代码行数:31,代码来源:backend.py

示例7: run

# 需要导入模块: from models import User [as 别名]
# 或者: from models.User import create_user [as 别名]
    def run( self, name, email, password):
        email = email.lower().strip()
        if( User.objects(email=email).count()):
            print "This email address already exists."
            return

        user = User.create_user( name, email, password)
        print "Created user with slug", user.slug
开发者ID:david1mdavis,项目名称:flask-sauth,代码行数:10,代码来源:commands.py

示例8: post

# 需要导入模块: from models import User [as 别名]
# 或者: from models.User import create_user [as 别名]
	def post(self):
		"""
		For a POST request, register a new doctor.
		"""

		fields = {field:self.request.get(field) for field in DOCTOR_REG_FIELDS}

		try:
			new_user = User.create_user(fields)
			self.redirect('/login')

		except Exception, error_msg:
			self.render('signup.html', error = error_msg, fields=fields, user = self.user)
开发者ID:sanketsaurav,项目名称:mseva,代码行数:15,代码来源:views.py

示例9: post

# 需要导入模块: from models import User [as 别名]
# 或者: from models.User import create_user [as 别名]
	def post(self):
		"""
		Create a new user, and redirect to homepage
		"""

		username = self.request.get('username')
		password = self.request.get('password')
		sex = self.request.get('sex')
		try:
			user = User.create_user(username, password, int(sex))
			self.render('login.html', success="Great! You are registered! Please log in.", user=user)

		except Exception, e:
			self.render('signup.html', error=e, user=self.user)
开发者ID:tanaykumarbera,项目名称:msgme-ch,代码行数:16,代码来源:views.py

示例10: register

# 需要导入模块: from models import User [as 别名]
# 或者: from models.User import create_user [as 别名]
def register(request):
    form = RegisterForm(request.POST)
    if form.is_valid():
        username = form.cleaned_data["username"]
        password = form.cleaned_data["password"]
        result = User.create_user(username, password)
        if result is True:
            messages.success(request, "Created Successfully! Please Login")
        elif isinstance(result, basestring):
            messages.error(request, result)
        return HttpResponseRedirect(reverse("twitter_home"))
    context = {
        'register_form': form,
        'login_form': LoginForm(),
    }
    return render(request, "twitter/index.html", context)
开发者ID:mitnk,项目名称:redis-twitter,代码行数:18,代码来源:views.py

示例11: post

# 需要导入模块: from models import User [as 别名]
# 或者: from models.User import create_user [as 别名]
    def post(self):
        """
        Create a new user, and redirect to homepage
        """

        username = self.request.get('username')
        password = self.request.get('password')
        group = self.request.get('group')
        college = self.request.get('college')

        try:
            user = User.create_user(group, college, username, password)
            self.render("login.html",
                        success="Great! You are registered! Please log in.", user=user)

        except Exception, e:
            self.render("signup.html", user=self.user, error=e)
开发者ID:kaushikdr,项目名称:campus,代码行数:19,代码来源:views.py

示例12: post

# 需要导入模块: from models import User [as 别名]
# 或者: from models.User import create_user [as 别名]
  def post(self):
    """Registers the user and updates datastore"""
    first_name = cgi.escape(self.request.get('first_name')).strip()
    last_name = cgi.escape(self.request.get('last_name')).strip()
    username = cgi.escape(self.request.get('username')).strip().lower()
    email = cgi.escape(self.request.get('email')).strip().lower()
    password = cgi.escape(self.request.get('password'))
    account = cgi.escape(self.request.get('account_type'))
    unique_properties = ['email_address']
    lower_first = first_name.lower()
    lower_last = last_name.lower()


    # Initial Creation of User      
    user_data = User.create_user(username,
    unique_properties, username=username,
    email_address=email, first_name=first_name, lower_first_name=lower_first, 
    password_raw=password,
    last_name=last_name, lower_last_name = lower_last, 
    subscriptions=["news", "techeria"], 
    account_type=account,
    verified=False)

    #send email verification
    message=mail.EmailMessage(sender="[email protected]",subject="Test your acct have been approved")
    message.to = email
    message.body = """Thank you!
      You have entered following information for register:
      Your mail: %s
      Your username: %s
      First Name: %s
      Last Name : %s 
      ------------------------------------------ ==>>""" % (email,username,first_name,last_name)
    message.send()
    # TODO: Look for new wait method
    time.sleep(1)
    try:
      u = self.auth.get_user_by_password(username, password, remember=True,
      save_session=True)
      self.redirect('/profile/{}'.format(self.user_model.username))
    except( auth.InvalidAuthIdError, auth.InvalidPasswordError):
      error = "Invalid Email/Password"
      self.response.out.write(template.render('views/login.html', {'error':error}))
开发者ID:tungply7,项目名称:Tutoring-Service,代码行数:45,代码来源:Authentication.py

示例13: post

# 需要导入模块: from models import User [as 别名]
# 或者: from models.User import create_user [as 别名]
    def post(self):
        """Attempts to create an account with the credentials provided in the
        post arguments.

        Successful creation logs the user in and sends them to '/'.

        Failure returns the user to the account create screen and tells them
        what went wrong.
        """
        username = self.get_argument("username")
        password = self.get_argument("password")

        try:
            u = User.create_user(username, password)
            u.validate()
            save_user(self.db_conn, u)
        except Exception, e:
            logging.error("Credentials failed")
            logging.error(e)
            form_fields = user_form(skip_fields=self.skip_fields, values={"username": username})
            return self.render_template("accounts/create.html", form_fields=form_fields)
开发者ID:B-Rich,项目名称:readify,代码行数:23,代码来源:handlers.py

示例14: post

# 需要导入模块: from models import User [as 别名]
# 或者: from models.User import create_user [as 别名]
    def post(self):
        """Attempts to create an account with the credentials provided in the
        post arguments.

        Successful creation logs the user in and sends them to '/'.

        Failure returns the user to the account create screen and tells them
        what went wrong.
        """
        username = self.get_argument('username')
        password = self.get_argument('password')
        email = self.get_argument('email')

        try:
            u = User.create_user(username, password, email)
            u.validate()
            save_user(self.db_conn, u)
        except Exception, e:
            logging.error('Credentials failed')
            logging.error(e)
            return self.render_template('accounts/create.html')
开发者ID:j2labs,项目名称:listsurf,代码行数:23,代码来源:handlers.py

示例15: post

# 需要导入模块: from models import User [as 别名]
# 或者: from models.User import create_user [as 别名]
    def post(self):
        username = self.request.get('username')
        user_data = User.create_user(username,
                                     email=self.request.get('email'),
                                     password_raw=self.request.get('password'),
                                     name=self.request.get('name'),
                                     last_name=self.request.get('lastname'),
                                     verified=False)
        if not user_data[0]:  # user_data is a tuple
            return self.display_message(
                'Unable to create user for email %s because of duplicate keys %s'
                % (username, user_data[1]))

        user_id = user_data[1].get_id()
        verification_type = 'signup'
        token = User.create_auth_token(user_id, verification_type)
        verification_url = self.uri_for('verification',
                                        verification_type=verification_type,
                                        user_id=user_id, token=token, _full=True)

        msg = 'Send an email to user in order to verify their address. \
          They will be able to do so by visiting <a href="{url}">{url}</a>'

        return self.display_message(msg.format(url=verification_url))
开发者ID:gsakkis,项目名称:webapp2-user-accounts,代码行数:26,代码来源:main.py


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