Exemplo n.º 1
0
    def _doPost(self, dataObject):

        if "email" in dataObject and "password" in dataObject:
            UM = UserMapper()
            ATM = ApitokenMapper()

            # Build user and token objects
            user = User()

            if not checkEmail(dataObject["email"]):
                raise BadRequest("The e-mail supplied was invalid.")

            user.setEmail(dataObject["email"])
            user.setPreHash(dataObject["password"])
            user.setRegistered(True)

            token = Apitoken()

            token.setUser(user)
            token.setToken(getKey())

            # Save changes to user
            try:
                UM.insert(user)

            # handle the possibility the user already exists
            except mdb.IntegrityError, e:
                raise Conflict(
                    "A user with that e-mail address exists already.")

            # handle all other DB errors
            except mdb.DatabaseError, e:
                raise ServerError(
                    "Unable to create user in the database (%s)" % e.args[1])
Exemplo n.º 2
0
    def _doPost(self, dataObject):

        if "email" in dataObject and "password" in dataObject:
            UM = UserMapper()
            ATM = ApitokenMapper()

            # Build user and token objects
            user = User()

            if not checkEmail(dataObject["email"]):
                raise BadRequest("The e-mail supplied was invalid.")

            user.setEmail(dataObject["email"])
            user.setPreHash(dataObject["password"])
            user.setRegistered(True)

            token = Apitoken()

            token.setUser(user)
            token.setToken(getKey())

            # Save changes to user
            try:
                UM.insert(user)

                # handle the possibility the user already exists
            except mdb.IntegrityError, e:
                raise Conflict("A user with that e-mail address exists already.")

                # handle all other DB errors
            except mdb.DatabaseError, e:
                raise ServerError("Unable to create user in the database (%s)" % e.args[1])
Exemplo n.º 3
0
	def _doCreateObject(self, data):
		"""Specifics required to build a User object given persistent storage data"""
		from Model.user import User
		user_ = User(data["id"])

		user_.setName(data["name"])
		user_.setPhoto(data["photo"])
		user_.setEmail(data["email"])
		user_.setPassword(data["password"])
		user_.setTime(data["time"])

		if data["registered"] == 1:
			user_.setRegistered(True)
		else:
			user_.setRegistered(False)

		return user_
Exemplo n.º 4
0
    def _doCreateObject(self, data):
        """Specifics required to build a User object given persistent storage data"""
        from Model.user import User
        user_ = User(data["id"])

        user_.setName(data["name"])
        user_.setPhoto(data["photo"])
        user_.setEmail(data["email"])
        user_.setPassword(data["password"])
        user_.setTime(data["time"])

        if data["registered"] == 1:
            user_.setRegistered(True)
        else:
            user_.setRegistered(False)

        return user_
Exemplo n.º 5
0
		else:
			# Anonymous login
			rdata = {}

			token = Apitoken()
			token.setToken(getKey())
			

			blank = User()
			blank.setToken(token)
			token.setUser(blank)

			umapper = UserMapper()
			ATM = ApitokenMapper()

			blank.setRegistered(False)

			# Save changes to user
			try:
				umapper.insert(blank)

			# handle the possibility the user already exists
			except mdb.IntegrityError, e:
				raise Conflict(CODE.CONFLICT, "A unexpected conflict occurred when trying to create your anonymous login token.")

			# handle all other DB errors
			except mdb.DatabaseError, e:
				raise ServerError("Unable to create user in the database (%s)" % e.args[1])

			# save the apitoken
			try: