2

I would like to render a specific Angular component after a serverside Python Flask process.

I would like to connect my user only if Password and Confirm_Password are the same. This check is done on the server for more security.

Here is my Flask code :

@app.route('/sign/', methods=['POST', 'GET'])
def register():
 if request.method == 'POST':
  users = mongo.db.users
  existing_user = users.find_one({'identifiant' : request.form['username']})
  if existing_user is None:
   if request.form['password']==request.form['password2']:
    hashpass = bcrypt.hashpw(request.form['password'].encode('utf-8'), bcrypt.gensalt())
    users.insert({'identifiant' : request.form['username'], 'email':request.form['email'], 'password' : hashpass})
   else:
    #return("Les mots de passes sont differents")
    return render_template("sign", message="Hello Flask!")
  else :
   return 'That username already exists!'
 return redirect(url_for('hello'))

If Password != Confirm_Password, I would like to render a specific component that says "Passwords are not the same". The issue is that I can't render a specific Angular component with Flask...

Théo.G
  • 37
  • 8
  • y are you trying to do this from python, you can do this in angular front end without even sending post request to flask – Nihal Apr 26 '19 at 10:08
  • check [this link](https://stackoverflow.com/questions/51605737/confirm-password-validation-in-angular-6) – Nihal Apr 26 '19 at 10:12
  • thanks for your msg ! I think that I don't understand this point. In my opinion, to create a full stack Single Page App, Angular = frontend, Flask = backend, MongoDB is my database. The routing is made by Angular. If I want to communicate with MongoDB I have to make POST and GET requests. If I want to make secure processes, I have to make it in the backend. But the communication between Flask and Angular is not working correclty, because I can't render a specific component in Flask. I don't know how to make it work. – Théo.G Apr 26 '19 at 10:16
  • My final question is : Is Angular.io a full stack app itself (front end + back end) or only the front end side ? – Théo.G Apr 26 '19 at 10:21
  • its on front end side you need somethings at back end, like MEAN stack or node js, or flask in your case which can interact with DB. but your problem of conforming password has no reason to connect to database, so that type of problems can be solved on front end its self – Nihal Apr 26 '19 at 10:25
  • okay thanks a lot ! And now for my connexion page : an user is entering his Mail and Password in an Angular Form. I send this informations to my database with Flask. If it's OK, I wanna return the User_Welcome_Page component and if not, I wanna return the Auth_Page with a message "You are not an existing user" for example. In each cases, how to return specific templates of Angular ? Thank you a lot !! – Théo.G Apr 26 '19 at 12:19

0 Answers0