コード例 #1
0
	def execute(self):
		if self.email is None and self.password is None:
			print("Create a new UserApp account.")

		if self.email is None:
			self.email=raw_input('email: ')

		if self.password is None:
			self.password=getpass.getpass('password: '******'retype same password: '******'server']['secure'],
			base_address=profile['server']['base_address'],
			debug=profile['server']['debug']
		)

		try:
			token=None
			token_identifier='UserApp CLI'

			signup_login=api.user.save(login=self.email, email=self.email, password=self.password)
			UserAppLoginCommand([self.email, self.password]).execute()

		except Exception, e:
			print("(error) " + str(e.message))
コード例 #2
0
	def execute(self):
		profile=self.config.get_selected_profile()
		
		if profile['user']['token'] is None:
			if profile['user']['login'] is None:
				print("(info) Not authenticated. Please login" + ('' if profile['user']['login'] is None else ' login as user' + profile['user']['login']) + '.')
			
			UserAppLoginCommand([profile['user']['login']]).execute()
			profile=self.config.get_selected_profile()

		api=userapp.API(
			app_id=__userapp_master_app_id__,
			secure=profile['server']['secure'],
			base_address=profile['server']['base_address'],
			debug=profile['server']['debug']
		)

		try:
			login_result=api.user.login(
				login=profile['user']['login'],
				password=profile['user']['password']
			)

			print("(result) Launching dashboard...")

			WebBrowserHelper.open_url('https://app.userapp.io/#/?ua_token='+str(login_result.token))
		except Exception, e:
			print("(error) " + str(e.message))
コード例 #3
0
def normal_user(app_id, login, password):
    """
    Example #1: A normal user logging in.  You can tell because the API
                token isn't set until we get it back from user_login().
    """

    api = userapp.API(app_id=app_id, debug=True)

    # Login our user
    results = api.user.login(login=login, password=password)

    token = results.token
    user_id = results.user_id
    lock_type = results.lock_type

    api.get_logger().debug("token={t}, user_id={u}, lock_type={l}".format(
        t=token, u=user_id, l=lock_type))

    # Retrieve the details for the logged in user.
    myself = api.user.get()

    # This will result in a count of 0, because a normal user doesn't
    # have access to see this sort of thing.
    count = api.user.count()

    api.user.logout()
コード例 #4
0
	def execute(self):
		if self.email is None and self.password is None:
			print("Enter your UserApp credentials.")

		if self.email is None:
			self.email=raw_input('email: ')

		if self.password is None:
			self.password=getpass.getpass('password: '******'server']['secure'],
			base_address=profile['server']['base_address'],
			debug=profile['server']['debug']
		)

		try:
			token=None
			token_identifier='UserApp CLI'

			login_result=api.user.login(login=self.email, password=self.password)

			app=api.app.get()
			tokens=api.token.search(fields='*')

			for item in tokens.items:
				if item.name == token_identifier:
					token=item.value

			if token is None:
				new_token=api.token.save(name=token_identifier, enabled=True)
				token=new_token.value

			profile=self.config.get_profile(self.email)

			profile['user']['primary']=False
			profile['user']['app_id']=app.app_id
			profile['user']['login']=self.email
			self.config.save()

			profile['user']['token']=token
			profile['user']['password']=self.password

			print("(result) Logged in as user " + login_result.user_id)

			if raw_input('Save credentials? ').lower() in ['yes', 'y', '']:
				self.config.save()

		except Exception, e:
			print("(error) " + str(e.message))
コード例 #5
0
    def get(self):
        # Create userapp client
        api = userapp.API(app_id=MY_APP_ID, debug=True, throw_errors=True)

        # create user
        api.user.save(login="******", password="******")

        # login user
        api.user.login(login="******", password="******")

        # exit user properties
        api.user.save(user_id="self", first_name="John", last_name="Doe")

        # logout user
        api.user.logout()

        self.render("index.html", message="User johndoe81 was created.")
コード例 #6
0
def admin_user(app_id, token):
    """
    Example #2: An admin logging in.  You can tell because we set the
                API token when we create the instance.
    """

    api = userapp.API(app_id=app_id, token=token, debug=True)

    # Get a count of all the users registered under this app ID.
    count = api.user.count()

    # Retrieve a list of all the users under this app ID.
    results = api.user.search()
    user_list = results.items

    # Retrieve the details for three users from the user list.
    results = api.user.get(user_id=[
        user_list[0].user_id, user_list[1].user_id, user_list[2].user_id
    ])

    # Test the nested Services
    results = api.user.invoice.search()
    results = api.user.paymentMethod.search()
コード例 #7
0
import config, userapp

api = userapp.API(app_id=config.USERAPP_APP_ID, debug=True, throw_errors=False)

user_result = api.user.login(login="******", password="******")
コード例 #8
0
        def wrapper(*args):
            request = args[1]

            request.userapp = Context(userapp.API(app_id=app_id), cookie_name)

            return f(*args)
コード例 #9
0
import config, userapp

api = userapp.API(app_id=config.USERAPP_APP_ID)

try:
	login_result = api.user.login(login="******", password="******")

	print("Authenticated using token {t} and user id {i}.".format(t=login_result.token, i=login_result.user_id))

	user = api.user.get()[0]

	print("Authenticated as user {u}, first name = {f}, last name = {l}, email = {e}.".format(u=user.login, f=user.first_name, l=user.last_name, e=user.email))

	api.user.logout()

	user_result = api.user.save(login="******", email="*****@*****.**", password="******")

	print("Saved new user {l} with user id {i}.".format(l=user_result.login, i=user_result.user_id))
except userapp.UserAppServiceException as e:
	print("An error occurred: {m} ({c}).".format(m=e.message, c=e.error_code))