def post(self): json_data = request.get_json() username = json_data.get('username') email = json_data.get('email') non_hash_password = json_data.get('password') if User.get_by_username(username): return {'message': 'username already'}, HTTPStatus.BAD_REQUEST if User.get_by_email(email): return {'message': 'email already exists'}, HTTPStatus.BAD_REQUEST password = hash_password(non_hash_password) user = User(username=username, email=email, password=password) user.save() data = { 'id': user.id, 'username': user.username, 'email': user.email } return data, HTTPStatus.CREATED
def post(self): data = Register.parser.parse_args() if User.find_by_username(data.username): return ResponseHandler.error('user exists', 400) user = User(**data) user.save() if user.id: return ResponseHandler.success('User Added', 200, data=user.json()) return ResponseHandler.error('user not added', 400)
def signin(): if request.method == "GET": return render_template('signin.html') elif request.method == "POST": form = request.form name = form['name'] email = form['email'] username = form['username'] password = form['password'] new_user = User(name=name, email=email, username=username, password=password) new_user.save() return redirect(url_for('index'))
def post(self): username = request.form.get('username') email = request.form.get('email') password = request.form.get('password') existing_user = User.query.filter_by(email=email).first() if not username or not email or not password: flash("Tüm alanları doldurun!", "signup") elif existing_user: flash("Geçersiz email adresi!", "signup") else: user = User(username=username, email=email, password=password) user.save() login_user(user) return redirect('/home') return redirect('/')