示例#1
0
def login():

    if request.method == 'POST':

        username = request.form['username']
        password = request.form['password']

        if bool(check_user(username)) and (check_user(username)['password']
                                           == password):
            session['username'] = username
            session['c_type'] = check_user(username)['c_type']
            return redirect(url_for('home'))
        return "Username or password incorrect.Try again"
    return redirect(url_for('home'))
示例#2
0
def signup():
    if request.method == 'POST':

        user_info = {
        }  #creating a dictionary to pass the below code into database - users

        user_info['username'] = request.form['username']
        user_info['email'] = request.form['email']
        user_info['password'] = request.form['password']
        rpassword = request.form['rpassword']
        user_info['c_type'] = request.form['type']
        if user_info['c_type'] == "buyer":
            user_info['cart'] = []

        if check_user(user_info['username']) is False:
            if rpassword == user_info['password']:
                create_user(
                    user_info
                )  #we are passing the dictionary into the function 'create_user'
            else:
                flash(
                    "passwords do not match, please provide correct password")
                return render_template("register.html")
        else:
            return "user already exists"

    return render_template("register.html")
示例#3
0
文件: auth.py 项目: aulicksah/Streamz
 def POST(self):
         data=web.data()
         un=json.loads(data)['username']
         pwd=json.loads(data)['password']
         passhash = hashlib.md5(pwd).hexdigest()
         id=model.check_user(un,passhash)
         return id
示例#4
0
def signup():

    if request.method == 'POST':

        user_info = {}

        user_info['username'] = request.form['username']
        user_info['full_name'] = request.form['full_name']
        user_info['password'] = request.form['password1']
        rpassword = request.form['password2']
        user_info['email'] = request.form['email']
        user_info['c_type'] = request.form['c_type']

        if user_info['password'] != rpassword:
            return "Passwords don't match.Go back and re-enter"

        if bool(check_user(user_info['username'])) is True:
            return "User already exists. Try logging in!"

        if user_info['c_type'] == 'buyer':
            user_info['cart'] = []

        add_user_to_db(user_info)
        session['username'] = user_info['username']
        session['c_type'] = user_info['c_type']
        return redirect(url_for('home'))

    return redirect(url_for('home'))
示例#5
0
def login():
    if request.method == 'POST':
        email = request.form['email']
        password = request.form['password']
        try:
            name = check_user(email, password)
        except AccountNotFound:
            return render_template('login.html', error=True)
        session['account'] = name
        return redirect('/users/' + name)
    return render_template('login.html')
示例#6
0
def login():
    if request.method == 'GET':
        return render_template('login.html')
    else:
        username = request.form['username']
        password = request.form['password']
        session['username'] = request.form['username']
        if model.check_user(username, password):
            return redirect(url_for('index'))
        else:
            return render_template('login.html', message='Login error')
示例#7
0
def register():
	error = None
	if request.method == 'POST':
		if model.check_user(escape(request.form['username'])):
			error = 'Username already exists'
		else:
			session['username'] = request.form['username']
			model.add_user(escape(request.form['username']), request.form['password'])
			flash('You were registered')
			return redirect(url_for('index'))
	return render_template('register.html', error=error, registering=True)
示例#8
0
def login():
	error = None
	if request.method == 'POST':
		test_password = model.check_user(escape(request.form['username']))
		if not test_password or test_password != request.form['password']:
			error = 'Invalid username/password combination'
		else:
			session['username'] = request.form['username']
			flash('Welcome back %s' % escape(request.form['username']))
			return redirect(url_for('index'))
	return render_template('login.html', error=error)
def login():
    login_info = view.login()
    if not model.check_user(login_info[0]):
        print("No user found, please register!")
        _ = input('\n\nHit any key to retry')
        return
    elif not model.check_login(login_info[0], login_info[1]):
        print("Password is wrong, please retry")
        _ = input('\n\nHit any key to retry')
        return
    else:
        print("User %s login successfully" % login_info[0])
        _ = input('\n\nHit any key to continue')
        return login_info[0]
示例#10
0
	def POST(self):
		login = self.login()
		if not login.validates():            
			return render.index(login)
		else:
			un=login.d.username
			pwd=login.d.password
			
			s= model.check_user(un,pwd)			
			if s['status']== "LoggedIn":
				session.loggedin = True
				session.user = s['username']
				raise web.seeother('/home')
			else:
				raise web.seeother('/')
示例#11
0
def login():
    if request.method == 'POST':

        uname = request.form['username']
        password = request.form['password']
        result = log_user(uname)

        if check_user(uname):

            if password == result['password']:
                session['username'] = result['username']
                session['type'] = result['c_type']
                return redirect(url_for('welcome'))
            return "enter the correct password"
        return "user doesn't exist"

        #return "login failed"
    #login=False
    return redirect(url_for('home'))
def login():
    '''returns (is_super,username) determined by the correct pair
    of username and password that the user has entered
    user can go back to the menu then is_super wil be resetted'''
    viewer.show_login()
    is_back = None
    while 1:
        username = viewer.ask_login_username()
        logged_super = model.check_user(username, viewer.ask_login_password())
        if logged_super[0]:
            break
        viewer.error_login()
        is_back = viewer.ask_back()
        if is_back:
            break
    is_super = None if is_back == True else logged_super[1]
    if is_super != None:
        viewer.done_login(is_super)
    return tuple([is_super, username])
示例#13
0
def login_submit():
    user     = bottle.request.forms.get('user')
    password = bottle.request.forms.get('password')
    
    message = ''
    #SHUO:check log in    
    message +='<p>[TEST] Login Module</p><hr/>'
    message += '<p>' + user+':' + password +'</p>'
    message += '<p> CHECK IN DATABASE, PLEASE WAIT...</p>'
   
    result = 0 
    for row in (model.check_login(user, password)):
        result = row['found']
    
    if(result >0):       
        #add session
        #add redirect
        message += '<p>FOUND '+str(result)+' matched users in database.</p>'
        bottle.response.set_cookie('sessionid', Session().create_session(user))
        #add redirect to a user specify page.
        #for now, test logout
        message +="""<p> Please click Log Out to exit</p>
                    <a href = "logout/<user>">Log Out</a>"""
        
    else:
        find_user = 0
        for row in (model.check_user(user)):
            find_user = row['find_user']
        
        if (find_user):
            message +="""<p>Username and Password doesn't match. Please re-check and login.:)</p>"""
            #bottle.redirect('/relogin')#not correct.
            bottle.redirect("relogin")
            #[MODIFY] link to login page
        else:
            message +="""<p> Welcome new user. Please Register first. :)</p>"""
            bottle.redirect('/user/'+user)
        #[MODIFY]should jump to different pages.     
    #set cookie
    #bottle.response.set_cookie('sessionid', user, 'asdf')
    #[MODIFY] ADD TO SESSION TABLES
    return message
示例#14
0
def send_welcome(message):
    id, name, value = check_user(message)

    if id == message.chat.id:
        update_state(message, DONE)
        bot.send_message(
            chat_id=message.chat.id,
            text=
            f'Привет {name} ваша суточная норма потребления воды составляет {value}мл.'
        )
        control_the_bot(message)
    else:
        bot.send_message(
            chat_id=message.chat.id,
            text=
            "Привет, пожалуйста, скажите ваше имя, чтобы я знал как к вам обращаться."
        )
        update_state(message, NAME)

        info_about_user['id'] = message.chat.id
示例#15
0
def login():
    error = None
    if request.method == 'POST':
        login_info = [request.form['username'], request.form['password']]
        if not model.check_user(login_info[0]):
            error = "No user found, please register!"
            return render_template('trader_login.html', error=error)

        elif not model.check_login(login_info[0], login_info[1]):
            error = "Password is wrong, please retry"
            return render_template('trader_login.html', error=error)

        else:
            print("User %s login successfully" % login_info[0])
            session['username'] = login_info[0]
            session['leverage'] = 25
            session['level'] = 0
            return redirect(url_for('select_page',username=login_info[0],leverage=session['leverage'],level=session['level']))
    else:
        return render_template('trader_login.html')
示例#16
0
文件: todo.py 项目: xiaoquan98/houmao
 def POST(self):
     sessionhook()
     
     web.header('Content-Type', 'application/json')
     dout = {}
     
     i = json.loads(web.data().decode("utf-8-sig"));
     username =i.get('name',None)
     password =i.get('password',None)
     
     session = web.config._session
     if model.check_user(username,password): 
     # if username == 'abcd' and password == '1234':
         session.access_token = 'true'
         # print "check user ok."
         dout["success"] = True
     else:
         session.access_token = 'false'
         dout["success"] = False
     return json.dumps(dout,sort_keys=True,indent=2,default=json_serial)
示例#17
0
def signup():

    if request.method == 'POST':
        user_info = {}

        user_info['username'] = request.form['username']
        user_info['email'] = request.form['email']
        user_info['password'] = request.form['password']
        rpassword = request.form['rpassword']
        user_info['c_type'] = request.form['ctype']
        if user_info['c_type'] == 'buyer':
            user_info['cart'] = []

        if check_user(user_info['username']) is False:
            if rpassword == user_info['password']:
                create_user(user_info)
                return "User id is created."
            else:
                return "password dont match"
        else:
            return "user already exists. Please chose a different username"

    return render_template('signup.html')
示例#18
0
def signup():

    if request.method == 'POST':

        userinfo = {}

        userinfo['username'] = request.form['username']
        userinfo['fullname'] = request.form['fullname']
        userinfo['password'] = request.form['password1']
        password2 = request.form['password2']
        userinfo['email'] = request.form['email']
        userinfo['type'] = request.form['type']

        if userinfo['password'] != password2:
            return "Password fields dint mantch"

        if bool(check_user(userinfo['username'])) is True:
            return "user already exists.try logging in"

        add_user_Todb(userinfo)
        return redirect(url_for('home'))

    return redirect(url_for('home'))
示例#19
0
def create_account(username, password, name):
    if model.check_user(username) == None:
        model.add_user(username, password, name, 100000)
        return 1
    else:
        return 0
示例#20
0
# Python Imports
from flask import Flask, render_template, request, url_for, redirect, session, g
import model, logging

# Local Imports
from controllers.parsing import parse

app = Flask(__name__)

app.secret_key = 'jumpingjacks'

username = ''
user = model.check_user()


@app.route('/', methods=['GET'])
def home_page():
    if 'username' in session:
        g.user = session['username']
        return render_template('football.html', message='login Successful')
    return render_template('homepage.html', message='Login or Signup!!!')


@app.route('/login', methods=['GET', 'POST'])
#@parse
def login():
    if request.method == 'POST':
        session.pop('username', None)
        username = request.form['username']
        pwd = request.form['password']
        if model.user_exists(username, pwd):