Ejemplo n.º 1
0
def factory(username="******",
            email="*****@*****.**",
            password="******"):
    hashed_pw = auth_logic.hash_password(password)
    user = User(username=username, email=email, password=hashed_pw)
    user.save()
    return user
Ejemplo n.º 2
0
def register_user(form):
    encoded_pw = form.password.data.encode('utf-8')
    hashed_password = auth_logic.hash_password(encoded_pw)
    user = User(username=form.username.data,
                email=form.email.data,
                password=hashed_password)
    user.save()
    return unicode(user.pk)
Ejemplo n.º 3
0
    def post(self):
        user_info = request.get_json(force=True)
        existing_user = UserModel.query.filter_by(
            email=user_info['email']).first()
        if existing_user:
            return error_response(message="This email address" +
                                  " has been taken",
                                  status=409)
        new_user = UserModel(**user_info)
        new_user.save()

        return success_response(
            message="Your account has been created successfully",
            data=UserSchema(exclude=['password']).dump(new_user),
            status=201)
Ejemplo n.º 4
0
def register_pool(username):
    if current_user.is_authenticated():
        flash("You are already logged in. Log out to register another account.", category="alert")
        return redirect(url_for('static_pages.landing_page'))

    if User.objects(name=username).first() is not None:
        flash("This user is already registered.", category="alert")
        return redirect(url_for('auth.login'))

    #Is verified
    auth_check = check_authenticated_ip(request.remote_addr, username=username)
    if auth_check:
        form = RegistrationForm(request.form)

        if request.method == "GET":
            return render_template('register_3.html', username=username, form=form, title="Step 3 - Register")

        elif request.method == "POST":
            if form.validate():
                uuid = auth_check.uuid.hex
                player = MinecraftPlayer.find_or_create_player(uuid, auth_check.username)
                user = User(
                    name=username,
                    hash=bcrypt.hashpw(form.password.data, bcrypt.gensalt()),
                    mail=form.mail.data,
                    minecraft_player=player)
                user.save()
                flash("Registration complete!", category="success")
                return redirect(url_for('auth.login'))
            return render_template('register_3.html', username=username, form=form, title="Step 3 - Register")

    #Is not verified
    else:
        if request.method == "GET":
            return render_template('register_2.html', username=username, title="Waiting... - Step 2 - Register")
        else:
            abort(405)
Ejemplo n.º 5
0
def factory(username="******", email="*****@*****.**", password="******"):
    hashed_pw = auth_logic.hash_password(password)
    user = User(username=username, email=email, password=hashed_pw)
    user.save()
    return user
Ejemplo n.º 6
0
    def run(self):
        arg = ''
        if len(self.argq) > 0:
            arg = self.argq.popleft()
        if arg == '' or arg == 'all':
            users = User.all()
            for user in users:
                w.user(user)
        elif arg == '+' or arg == 'add':
            if len(self.argq) > 0:
                # Si se pasaron los datos de manera directa
                pass
            name = raw_input('Ingrese nombre>>> ')
            username = raw_input('Ingrese nombre de usuario>>> ')
            email = raw_input('Ingrese email>>> ')
            user = User()
            user.name = name
            user.username = username
            user.email = email
            if user.save():
                #w.success('')
                pass
            else:
                w.error("Error al guardar")
        elif arg == 'del' or arg == '-d':
            if len(self.argq) < 1:
                w.error('No eligió ningun elemento para borrar. Pruebe alguno de los siguientes comandos')
                w.warning('  track -u -d \#1', True, '\t#1 para el elemento cuyo id es 1')
                w.warning('  track -u -d @username', True, '\t@username para borrar a @username')
            else:
                arg = self.argq.popleft()
                if arg.find('#') > -1:
                    user = User.find(int(arg[1:]))
                    if user == None:
                        w.error('No existe el usuario: '+str(arg))
                        exit()
                elif arg.find('@')  > -1:
                    user = User.find(arg[1:], False)
                    if user == None:
                        w.error('No existe el usuario: '+str(arg))
                        exit()
                if user.delete():
                    w.success('@'+user.username, True, ' eliminado')

        elif arg == 'me' or arg == '-m':
            #tareas asignadas a mí
            user = User.find(Config.getUser().username, False)
            if user != None:
                w.user(user, True)
        elif arg == 'list' or arg == '-l':
            # Mostrar lista de comandos con ejemplo
            self.showCommandsList()
        elif arg == '-h' or arg == 'help':
            # Mostrar ayuda
            self.showHelp()
        else:
            if arg.find('#') > -1:
                #Si se quiere ver una tarea en especifico
                user = User.find(int(arg[1:]))
                if user != None:
                    w.user(user, True)
                    exit()
            elif arg.find('@')  > -1:
                # Las tareas de un usuario en especifico
                user = User.find(arg[1:], False)
                if user == None:
                    w.error('No existe el usuario: '+str(arg))
                    exit()
                w.user(user, True)
            else:
                print 'Parámetro desconocido. Puede probar los siguientes:'
                print '\ttracker users [-u] list [-l]\tLista de comandos'
                print '\ttracker users [-u] help [-h]\tAyuda'
                print 'Si se omite el parámetro, se listan todos los elementos'