def create_crypt(password):
    """
    Create a basic crypted password hash to use on the system.

    password -- password string that has not been crypted
    """
    
    manager = CRYPTPasswordManager('$1$')
    return manager.encode(password)
Exemple #2
0
	def post(self):
		username = self.request.POST['username']
		password = self.request.POST['password']
		user = User.gql("where email = :1",username)
		user = user.get()
		if user is None:
			self.session.add_flash("Invalid Username!",key='error')
			self.redirect("/login")
		else:
			manager = CRYPTPasswordManager(SHA256CRYPT)
			if manager.check(user.password,password):
				self.session["current_user"] = str(user.key())
				self.redirect("/")
			else:
				self.session.add_flash("Invalid Password!",key='error')
				self.redirect("/login")
Exemple #3
0
	def post(self):
		username = self.request.POST['username']
		passwor = self.request.POST['password']
		gender = self.request.POST['sex']
		manager = CRYPTPasswordManager(SHA256CRYPT)
		password=manager.encode(passwor)
				
		if re.match("^[a-zA-Z0-9._%-]+@[a-zA-Z0-9._%-]+.[a-zA-Z]{2,6}$", username) != None:
			
			q = db.GqlQuery("SELECT * from User where email = :1",username)
			a = q.get()			
			if a is not None:
				self.session.add_flash("Username already exists!",key='error')
				self.redirect("/signup")
			else:
				User.create(username,password,gender)
				self.redirect("/login")
		else:
			self.session.add_flash("Enter valid email!",key='error')
			self.redirect("/signup")