コード例 #1
0
ファイル: app.py プロジェクト: CharisaP/pokedex
def addUser():
    error = None
    if request.method=='POST':
        username = request.form['username']
        password = request.form['password']

        thisuser = request.form['username']

        users = dbHandler.retrieveUsers()

        x = (request.form['username'], request.form['password'])
        print users
        print x
        if x in users:
            print "error"
            error = 'Username already exists. Please try again.'

            return render_template('addUser.html', error=error)
        else:
            dbHandler.addUser(username, password)
            session['logged_in'] = True
            session['currentuser'] = thisuser
            g.user = username
            return redirect(url_for('home'))
    else:

        return render_template('addUser.html',error=error)
コード例 #2
0
def addrec():
    if request.method == "GET":
        print "HI - in init"
        res, msg = dbHandler.addUser(request.args)
    else:
        res, msg = dbHandler.addUser(request.form)

    return 'hope working'
コード例 #3
0
ファイル: views.py プロジェクト: JaShao/PublicActivity
def checkUsedEmail(request):
    if 'email' in request.POST:
        if md.checkEmail(email):
            md.addUser(email, password, user_type)
            return HttpResponse("{'status': '1'}")
        else:
            return HttpResponse("{'status': '0', 'message' : 'Email already in use'}")
    return HttpResponse("{}")
コード例 #4
0
ファイル: run.py プロジェクト: weizhimeng/biyesheji
def register():
    form = RegisterFrom()
    # 如果是post方法并且表单验证通过的话, 返回True;
    if form.validate_on_submit():
        # 用户提交的表单信息
        print(form.data)
        addUser(form.data['user'], form.data['passwd'])
        return redirect(url_for('index'))
        # return 'ok'
    return render_template('register.html', form=form)
コード例 #5
0
ファイル: main.py プロジェクト: RamonaAnca/whereShouldIGo
def index_page():
    username = ""
    if session.get('logged_in') == True:
        username = session['username']
    if request.method == 'POST':
        password = request.form['password']
        dbHandler.addUser(username, password)
        user = dbHandler.retrieveUsers()
        return render_template('index.html', username=username)
    else:
        return render_template('index.html')
コード例 #6
0
ファイル: views.py プロジェクト: JaShao/PublicActivity
def s_signup(request):
    if 'email' in request.POST and 'username' in request.POST and 'password' in request.POST and 'tags' in request.POST and 'gender' in request.POST  and "user_type" in request.POST:
        gender = request.POST['gender']
        tags = request.POST['tags']
        username = request.POST['username']
        email = request.POST['email']
        password = request.POST['password']
        user_type = request.POST['user_type']
        if user_type == "1" or user_type == "0":
            if validEmail(email) and validPassword(password):
                if md.checkEmail(email):
                    md.addUser(email, password, user_type, gender, username, tags)
                    return HttpResponse("{'status': '1'}")
                else:
                    return HttpResponse("{'status': '0', 'message' : 'Email already in use'}")

    return HttpResponse("{}")
コード例 #7
0
ファイル: views.py プロジェクト: Ethan-zhengyw/PublicActivity
def s_signup(request):
    if 'email' in request.POST and 'username' in request.POST and 'password' in request.POST and 'tags' in request.POST and 'gender' in request.POST:
        gender = int(request.POST['gender'])
        tags = request.POST['tags']
        username = request.POST['username']
        email = request.POST['email']
        password = request.POST['password']
        if validEmail(email) and validPassword(password):
            if md.checkEmail(email):
                md.addUser(email, password, gender, username, tags)
                return HttpResponse("{'status': '1'}")
            else:
                return HttpResponse("{'status': '0', 'message' : 'Email already in use'}")
        else:
            if not validEmail(email):
                print "email"
            if not validPassword(password):
                print "password"
    return HttpResponse("{}")
コード例 #8
0
ファイル: views.py プロジェクト: liddiard/cs253-wiki
 def post(self):
     username = self.request.get('username')
     password = self.request.get('password')
     verify = self.request.get('verify')
     email = self.request.get('email')
     
     errors = utils.createErrorArgs(utils.usernameError(username),
                           utils.passwordsError(password, verify),
                           utils.emailError(email))
     
     if errors is None: # registration successful
         pw_hash = utils.makePasswordHash(username, password)
         models.addUser(username, pw_hash, email)
         user_cookie = utils.makeSecureVal(username)
         utils.setCookie(self, key="username", val=user_cookie)
         self.redirect("/signup/success/")
     
     else: # registration unsuccessful
         self.render("register.html", username=username, password=password, 
                     verify=verify, email=email, errors=errors)
コード例 #9
0
ファイル: main.py プロジェクト: RamonaAnca/whereShouldIGo
def signUp_page():
    if request.method == "GET":
        return render_template("signUp.html")
    if request.method == 'POST':
        username = request.form['username']
        password = request.form['password']
        confirmPassword = request.form['password2']
        if password == confirmPassword:
            userId = dbHandler.getUserId(username)
            if len(userId) == 1:
                flash("Username already exists")
                return render_template('signUp.html')
            else:
                dbHandler.addUser(username, password)
                userId = dbHandler.getUserId(username)
                session['logged_in'] = True
                session['username'] = username
                session['userid'] = userId[0][0]
                return redirect(url_for('index_page'))
        else:
            flash("Password must match")
            return render_template('signUp.html')
コード例 #10
0
ファイル: app.py プロジェクト: pnr14b/pokedex
def addUser():
    error = None
    if request.method == 'POST':
        username = request.form['username']
        password = request.form['password']
        users = dbHandler.retrieveUsers()

        x = request.form['username']
        print x

        for y in users:
            if x in y[0]:
                error = 'Username already exists. Please try again.'
                return render_template('addUser.html', error=error)

        else:
            dbHandler.addUser(username, password)
            session['logged_in'] = True
            return redirect(url_for('home'))

    else:

        return render_template('addUser.html', error=error)
コード例 #11
0
def createTopPlaylist():

    # save IDs in case user chose autoupdate
    playlist_id_short = None
    playlist_id_medium = None
    playlist_id_long = None
    playlist_uri = ''

    # create playlist, then get TopTracks, then fill playlist with TopTracks
    if 'short_term' in request.form:
        playlist_id_short, playlist_uri = createPlaylist(
            session, request.form['short_term_name'])
        uri_list = getTopTracksURI(session, 'short_term', 50)
        addTracksPlaylist(session, playlist_id_short, uri_list)

    if 'medium_term' in request.form:
        playlist_id_medium, playlist_uri = createPlaylist(
            session, request.form['medium_term_name'])
        uri_list = getTopTracksURI(session, 'medium_term', 50)
        addTracksPlaylist(session, playlist_id_medium, uri_list)

    if 'long_term' in request.form:
        playlist_id_long, playlist_uri = createPlaylist(
            session, request.form['long_term_name'])
        uri_list = getTopTracksURI(session, 'long_term', 50)
        addTracksPlaylist(session, playlist_id_long, uri_list)

    # if user selects autoupdate, add them to the database
    if 'auto_update' in request.form:
        addUser(session['user_id'],
                session['refresh_token'],
                playlist_id_short=playlist_id_short,
                playlist_id_medium=playlist_id_medium,
                playlist_id_long=playlist_id_long)

    # send back the created playlist URI so the user is redirected to Spotify
    return playlist_uri
コード例 #12
0
def on_login_complete(data):
    # print("inside fb login")
    if data['fb_user_token']:
        loggedInFrom = 'Facebook'
        response = requests.get(
            'https://graph.facebook.com/v2.8/me?fields=id%2Cname%2Cpicture&access_token='
            + data['fb_user_token'])
        json = response.json()
        name = json['name']
        link = json['picture']['data']['url']

    elif data['google_user_token']:
        loggedInFrom = 'Google'
        response = requests.get(
            'https://www.googleapis.com/oauth2/v3/tokeninfo?id_token=' +
            data['google_user_token'])
        json = response.json()
        name = (json['given_name'] + " " + json['family_name'])
        link = json['picture']
    welcome_message = bot.botResponses(
        ("!! say Everyone! " + name +
         " has finally come to the great city of Pawnee!!"))
    models.addMessage(1, bot.botID, welcome_message)
    all_messages = models.getChatMessages(1)
    if models.userExists(link):
        user = models.getUser(link)
        key = user['userID']
        join_room(key)
        print("*************************user*************", user)
        if key not in users_connected:
            users_connected[key] = user
        connectedList = list(users_connected.values())
        print("*************************connectedList*************",
              connectedList)
        print(len(connectedList))
        connectedCount = len(users_connected)
        socketio.emit('login success', {
            "isLoggedIn": 1,
            'loggedInFrom': loggedInFrom,
            'user': user,
            'messages': all_messages,
            'connected_users': connectedList,
            'numberOfUsers': connectedCount
        },
                      broadcast=True,
                      room=key)

    else:
        new_user = models.addUser(name, link)
        nu_ = models.getUserByID(new_user.userID)
        key = nu_['userID']
        join_room(key)
        print("*************************user*************", nu_)
        if key not in users_connected:
            users_connected[key] = nu_
        connectedList = list(users_connected.values())
        connectedCount = len(users_connected)
        socketio.emit('login success', {
            "isLoggedIn": 1,
            'loggedInFrom': loggedInFrom,
            'user': nu_,
            'messages': all_messages,
            'connected_users': connectedList,
            'numberOfUsers': connectedCount
        },
                      broadcast=True,
                      room=key)