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


Python User.login方法代码示例

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


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

示例1: Login

# 需要导入模块: from parse_rest.user import User [as 别名]
# 或者: from parse_rest.user.User import login [as 别名]
def Login(userIDClass):
    global username, userDetails
    username = usernameEntry.get()
    password = passwordEntry.get()
    myClassName = 'User'
    myClass = Object.factory(myClassName)
    username = str(username.lower())
    Id = userDetails[username]
    print(Id)
    data = myClass.Query.get(objectId = Id)
    teacher = data.teacher
    print(teacher)
    if username in userDetails:
        print('Logging in')
        try:
            User.login(username, password)
            print('Logged in')
            currentUserLabel.config(text = 'Logged in as '+username+'. Class: '+userIDClass[Id])
            if teacher == False:
                outputUserResults()
                newWordButton.config(state = DISABLED)
                quizSelectButton.config(state = NORMAL)
            else:
                newWordButton.config(state = NORMAL)
                quizSelectButton.config(state = DISABLED)
                resultsList.delete(0, END)
                findTeachersPupils(Id)
        except:
            print('Incorrect password')
            currentUserLabel.config(text = 'Incorrect password')
    else:
        currentUserLabel.config(text = 'That is an invalid username')
        print('That is an invalid username')
    print('FUNCTION: userLogin COMPLETE')
    print(time.asctime( time.localtime(time.time()) ))
开发者ID:domahutch,项目名称:Spelling-bee,代码行数:37,代码来源:Parse+Version+(Slow).py

示例2: test_today_pings

# 需要导入模块: from parse_rest.user import User [as 别名]
# 或者: from parse_rest.user.User import login [as 别名]
  def test_today_pings(self):
    assignTask = Function("assignTask")
    ping = Function("ping")
    u1 = User.login('redsox55', 'secure123')
    assignee = User.Query.get(username='deepthroat')
    with SessionToken(u1.sessionToken):
      title = 'serha34g444'
      response = assignTask(
        title=title,
        description="Send a ping to this task",
        watchers=[u[2] for u in sample_users],
        score=2,
        assignee=assignee.email,
      )
    self.assertIn('task', response['result'])

    todayPings = Function('todayPings')
    with SessionToken(u1.sessionToken):
      task = Task.Query.get(title=title)
      ping(taskId=task.objectId)
      todayPingsU1 = todayPings()
    print "TODAY PINGS U1: %s" % todayPingsU1
    self.assertEqual(len(todayPingsU1['result']), 1)

    u2 = User.login('baracky', 'usanumber1')
    with SessionToken(u2.sessionToken):
      ping(taskId=task.objectId)
      ping(taskId=task.objectId)
      todayPingsU2 = todayPings()
    print "TODAY PINGS U2: %s" % todayPingsU2
    self.assertEqual(len(todayPingsU2['result']), 2)
开发者ID:danrobinson,项目名称:PingBox,代码行数:33,代码来源:tests.py

示例3: delete_sample_users

# 需要导入模块: from parse_rest.user import User [as 别名]
# 或者: from parse_rest.user.User import login [as 别名]
def delete_sample_users():
  for username, password, email in sample_users:
    try:
      u = User.login(username, password)
      u.delete()
    except:
      pass
开发者ID:danrobinson,项目名称:PingBox,代码行数:9,代码来源:tests.py

示例4: test_create_task

# 需要导入模块: from parse_rest.user import User [as 别名]
# 或者: from parse_rest.user.User import login [as 别名]
  def test_create_task(self):
    assignTask = Function("assignTask")

    assignee = User.Query.get(username='deepthroat')
    u = User.login('redsox55', 'secure123')
    with SessionToken(u.sessionToken):
      title = 'w45h45r4g4h'
      response = assignTask(
        title=title,
        description="See title",
        watchers=[user[2] for user in sample_users],
        email=None,
        assignee=assignee.email,
      )
    self.assertIn('task', response['result'])

    tasks = Task.Query.all()
    self.assertEqual(len(tasks), 1)
    t = tasks[0]
    self.assertEqual(t.title, title)
    self.assertEqual(t.creator.objectId, u.objectId)
    self.assertEqual(t.score, 0)
    self.assertEqual(len(t.watchers), len(sample_users))
    self.assertEqual(t.assignee.objectId, assignee.objectId)

    self.assertTrue(all(w["className"] == '_User' for w in t.watchers))
开发者ID:danrobinson,项目名称:PingBox,代码行数:28,代码来源:tests.py

示例5: circles

# 需要导入模块: from parse_rest.user import User [as 别名]
# 或者: from parse_rest.user.User import login [as 别名]
def circles():
    if 'username' in session:
        username = escape(session['username'])
        password = escape(session['password'])
        user = User.login(username, password)
        if request.method == 'POST':
            circle = Circle(name=request.form['name'])
            circle.users = [user]
            circle.owner = user
            user.circles.append(circle)
            circle.save()
            user.save()
            return redirect(url_for('circles'))
        req = Request.Query.filter(toUser=username)
        friends = []
        circles = []
        for c in user.circles:
            circle = Circle.Query.get(objectId=c.get('objectId'))
            circles.append(circle)
            if circle.name == 'all':
                for u in circle.users:
                    friend = User.Query.get(objectId=u.get('objectId'))
                    if friend.objectId != user.objectId:
                        friends.append(friend)
        return render_template('circles.html', user=user, req=req, friends=friends, circles=circles)
    else:
        return render_template('signup.html')
开发者ID:hspak,项目名称:cs390python,代码行数:29,代码来源:main.py

示例6: dashboard

# 需要导入模块: from parse_rest.user import User [as 别名]
# 或者: from parse_rest.user.User import login [as 别名]
def dashboard():
    u = User.login("arjun", "password")
    fname = u.fname
    lname = u.lname
    username = u.username

    name = fname + " " + lname
    email=u.email
    zipcode = u.zipcode
    state = u.state
    address = u.streetAddress
    city = u.city

#     monthly = getMonthlyRates("arjun")
#     cost = monthly["cost"]
#     cost = round(cost, 2)
#     split = monthly["split"]
#
#     water = split["water"]
#     gas = split["gas"]
#     electric = split["electric"]

    water = 57.39
    electric = 139.16
    gas = 140.74
    cost = 337


    billDue = dueDate().strftime("%A, %B %d")
    return render_template('dashboard.html', dueDate=billDue, name=name, email=email, city=city, address=address, state=state, zipcode=zipcode, cost=cost, water=water, gas=gas, electric=electric)
开发者ID:DakotaNelson,项目名称:PayableVIP,代码行数:32,代码来源:app.py

示例7: test

# 需要导入模块: from parse_rest.user import User [as 别名]
# 或者: from parse_rest.user.User import login [as 别名]
def test():
    u = User.login("arjun", "password")

#     print predictBills(6, 'arjun')
    print getMonthlyRates("arjun")

    return render_template('test.html', u="blah")
开发者ID:DakotaNelson,项目名称:PayableVIP,代码行数:9,代码来源:app.py

示例8: makePayment

# 需要导入模块: from parse_rest.user import User [as 别名]
# 或者: from parse_rest.user.User import login [as 别名]
def makePayment():
    req = request.get_json()

    if req is None:
        return json.dumps({"status": "fail",
                "reason": "Must include JSON."})

    # TODO authentication to make sure this user
    #      has permission to do this
    if not 'username' in req or not 'password' in req:
        return json.dumps({"status": "fail",
                "reason": "Must include username and password."})

    if not 'amount' in req:
        return json.dumps({"status": "fail",
                "reason": "Must include payment amount."})

    # make sure we can validate to the db
    try:
        u = User.login(req['username'], req['password'])
    except:
        return json.dumps({"status": "fail",
                "reason": "Unable to log user in."})

    # attempt the payment
    res = achCharge(float(req['amount']), u.routingNo, u.acctNo)
    if res['CmdStatus'] != 'Approved':
        return json.dumps({"status": "fail",
                "reason": "Unable to charge account."})

    u.acctBalance += float(req['amount'])
    u.save()
    return json.dumps({"status":"success"})
开发者ID:DakotaNelson,项目名称:PayableVIP,代码行数:35,代码来源:app.py

示例9: parse_login

# 需要导入模块: from parse_rest.user import User [as 别名]
# 或者: from parse_rest.user.User import login [as 别名]
def parse_login(email, password):	
	
	email = email.lower()

	try:
		user = get_parse_user_by_email(email)
	except:
		return {'error': "No one has signed up with this address."}
	
	# only check for verified addresses on users who signed up after initializing email verification
	try:
		if user.emailVerified == False:
			return {'error': "Email address not verified. Please check inbox."}
	except:
		pass

	u = ParseUser.login(email, password)
	header = u.session_header()
	
	response = {'token': header['X-Parse-Session-Token'],
				}
				#'chargify_active': u.chargify_active,
				#'active': u.active,
				#'user': u,
	
	try:
		response['ref'] = u.ref
		response['staff'] = False
	except:
		response['ref'] = None
		response['staff'] = True
		
	return response
开发者ID:rhouck,项目名称:market,代码行数:35,代码来源:utils.py

示例10: setUp

# 需要导入模块: from parse_rest.user import User [as 别名]
# 或者: from parse_rest.user.User import login [as 别名]
    def setUp(self):
        self.username = TestUser.USERNAME
        self.password = TestUser.PASSWORD
        self.game = None

        try:
            u = User.login(self.USERNAME, self.PASSWORD)
        except ResourceRequestNotFound:
            # if the user doesn't exist, that's fine
            return
        u.delete()
开发者ID:hsenju,项目名称:Goober,代码行数:13,代码来源:tests.py

示例11: login_button

# 需要导入模块: from parse_rest.user import User [as 别名]
# 或者: from parse_rest.user.User import login [as 别名]
 def login_button(self):
     try:
         u = User.login(self.username.text, self.password.text)
         app = kivy.app.App.get_running_app()
         app.user = u
         if not self.manager.has_screen('home'):
             self.manager.add_widget(HomeScreen(name='home'))
         self.manager.current = 'home'
     except ParseError:
         self.error.text = "Login Failed. Try again."
         self.error.color = [1,0,0,1]
开发者ID:celee,项目名称:MEET-mobile,代码行数:13,代码来源:main.py

示例12: index

# 需要导入模块: from parse_rest.user import User [as 别名]
# 或者: from parse_rest.user.User import login [as 别名]
def index():
 	settings_local.initParse()
	if request.method == 'POST' and request.form["what"]== 'Login':
		try:
			print request.form["password"]
			u = User.login(request.form["username"],request.form["password"])
			session['session_token'] = u.sessionToken
			resp = make_response(render_template("index.html"))
			return resp
		except:
			return render_template('login.html',error="Invalid username or password")
	elif request.method == 'POST' and request.form["what"]=='SignUp':
		email = request.form["email"]
		password = request.form["password"]
		ninja = request.form["ninja"]
		birthdate = request.form["birthdate"]
		u = User.signup(email,password)
		u.email=email
		u.save()
		# proPic.save(os.path.join(app.config['UPLOAD_FOLDER']),"userdp.png")
		# connection = httplib.HTTPSConnection('api.parse.com', 443)
		# connection.connect()
		# connection.request('POST', '/1/files/profilePic.png', open('userdp.png', 'rb').read(), {
		# "X-Parse-Application-Id": "${Y4Txek5e5lKnGzkArbcNMVKqMHyaTk3XR6COOpg4}",
		# "X-Parse-REST-API-Key": "${nJOJNtVr1EvNiyjo6F6M8zfiUdzv8lPx31FBHiwO}",
		# "Content-Type": "image/png"
		# })
		# result = json.loads(connection.getresponse().read())
		# print result
		# connection.request('POST', '/1/classes/_User', json.dumps({
		# "username": email,
		# "picture": {
		#  "name": "profilePic.png",
		#  "__type": "File"
		# }
		# }), {
		# "X-Parse-Application-Id": "${Y4Txek5e5lKnGzkArbcNMVKqMHyaTk3XR6COOpg4}",
		# "X-Parse-REST-API-Key": "${nJOJNtVr1EvNiyjo6F6M8zfiUdzv8lPx31FBHiwO}",
		# "Content-Type": "application/json"
		# })
		# result = json.loads(connection.getresponse().read())
		# print result
		session['session_token'] = u.sessionToken
		resp = make_response(render_template("index.html"))
		return u.sessionToken
	else:
		if session.get('session_token') is None:
			print "nohhh"
			return render_template('login.html')
		else:
			print "yes"
			return render_template('index.html')
开发者ID:jaygagnani,项目名称:Punchit.io_website_master,代码行数:54,代码来源:hello.py

示例13: fakeNewRunFromCSV

# 需要导入模块: from parse_rest.user import User [as 别名]
# 或者: from parse_rest.user.User import login [as 别名]
def fakeNewRunFromCSV(csvLines, updateFrequency, length, objID, username, pwd):
    '''
    use like this...
    fakeNewLocations(runnerLocations, 1, 40)
    runnerLocations is the query,
    1 is going to send the next location every 1 second,
     and will do this for 40 seconds
    '''
    u = User.login(username, pwd)
    updateNum = 0
    for line in csvLines[1:]:
        lat, lon, time, username, user_objid, dist, runT, speed = line.strip().split(",")
        rl = RunnerLocations(location=GeoPoint(latitude=float(lat), longitude=float(lon)),
                            time = datetime.datetime.now(),
                            user = u,
                            distance = float(dist),
                            duration = runT, 
                            speed = float(speed))
        rl.save()

        connection = httplib.HTTPSConnection('api.parse.com', 443)
        objectPath = '/1/classes/CurrRunnerLocation/' + objID
        connection.connect()
        connection.request('PUT', objectPath, json.dumps({
            
            "time": {
                "__type": "Date",
                "iso": datetime.datetime.utcnow().isoformat()
            },
            "speed": float(speed),
            "duration": runT,
            "distance": float(dist),
            "location": {
                "__type": "GeoPoint",
                "latitude": float(lat), 
                "longitude": float(lon)
            }
        }), {
            "X-Parse-Application-Id": "QXRTROGsVaRn4a3kw4gaFnHGNOsZxXoZ8ULxwZmf",
            "X-Parse-REST-API-Key": "BCJuFgG7GVxZfnc2mVbt2dzLz4bP7qAu16xaItXB",
            "Content-Type": "application/json"
        })
        result = json.loads(connection.getresponse().read())
        print result

        print "updated %s times" % updateNum
        print "distance : %s , duration : %s" % (rl.distance, rl.duration)
        updateNum += 1
        if (updateNum > length):
            break
        sleep(updateFrequency)
开发者ID:NUDelta,项目名称:CrowdCheer_testScripts,代码行数:53,代码来源:fakeRunner.py

示例14: index

# 需要导入模块: from parse_rest.user import User [as 别名]
# 或者: from parse_rest.user.User import login [as 别名]
def index():
    if 'username' in session:
        username = escape(session['username'])
        password = escape(session['password'])
        user = User.login(username, password)
        if request.method == 'POST':
            post = Post(text=request.form['post'])
            file = request.files['file']
            if file:
                filename = secure_filename(file.filename)
                file.save(os.path.join(app.config['UPLOAD_FOLDER'], filename))
                headers = {
                "X-Parse-Application-Id": "h2Co5EGV2YoBuPL2Cl7axkcLE0s9FNKpaPcpSbNm",
                "X-Parse-REST-API-Key": "o59euguskg7BBNZlFEuVxTNL0u93glStq7memfVH",
                "Content-Type": "image/jpeg"
                }
                connection = httplib.HTTPSConnection('api.parse.com', 443)
                connection.connect()
                connection.request('POST', '/1/files/' + filename, open(filename, 'rb'), headers)
                result = json.loads(connection.getresponse().read())
                post.imgUrl = result['url'];

            post.circles = user.postingTo
            post.user = user
            post.save()
            return redirect(url_for('index'))
        else:
            posts = []
            allFriends = Circle.Query.get(owner=user, name="all")
            for friend in allFriends.users:
                friendObj = User.Query.get(objectId=friend.get('objectId'))
                circlesIAmIn = []
                for circle in friendObj.circles:
                    circleObj = Circle.Query.get(objectId=circle.get('objectId'))
                    for u in circleObj.users:
                        if u.get('objectId') == user.objectId:
                            circlesIAmIn.append(circleObj.name)
                friendPosts = Post.Query.filter(user=friendObj)
                for post in friendPosts:
                    for i in circlesIAmIn:
                        if i in post.circles:
                            posts.append(post)
                            break

            sortedPosts = sorted(posts, key=lambda x: x.createdAt, reverse=True)
            return render_template('home.html', user=user, posts=sortedPosts)
    else:
        session.pop('username', None)
        session.pop('password', None)
        return render_template('signup.html')
开发者ID:hspak,项目名称:cs390python,代码行数:52,代码来源:main.py

示例15: login

# 需要导入模块: from parse_rest.user import User [as 别名]
# 或者: from parse_rest.user.User import login [as 别名]
def login():
    if request.method == 'POST':
        username = request.form['username']
        password = request.form['password']
        session['username'] = username
        session['password'] = password
        u = User.login(username, password)
        u.save()
        return redirect(url_for('index'))
    else:
        if 'username' in session:
            return redirect(url_for('index'))
        else:
            return render_template('login.html', new=True)
开发者ID:hspak,项目名称:cs390python,代码行数:16,代码来源:main.py


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