Method: Spaceship::Client#login
- Defined in:
- spaceship/lib/spaceship/client.rb
#login(user = nil, password = nil) ⇒ Spaceship::Client
Authenticates with Appleās web services. This method has to be called once to generate a valid session. The session will automatically be used from then on.
This method will automatically use the username from the Appfile (if available) and fetch the password from the Keychain (if available)
375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 |
# File 'spaceship/lib/spaceship/client.rb', line 375 def login(user = nil, password = nil) if user.to_s.empty? || password.to_s.empty? require 'credentials_manager/account_manager' puts("Reading keychain entry, because either user or password were empty") if Spaceship::Globals.verbose? keychain_entry = CredentialsManager::AccountManager.new(user: user, password: password) user ||= keychain_entry.user password = keychain_entry.password(ask_if_missing: !Spaceship::Globals.check_session) end if user.to_s.strip.empty? || password.to_s.strip.empty? exit_with_session_state(user, false) if Spaceship::Globals.check_session raise NoUserCredentialsError.new, "No login data provided" end self.user = user @password = password begin do_login(user, password) # calls `send_login_request` in sub class (which then will redirect back here to `send_shared_login_request`, below) rescue InvalidUserCredentialsError => ex raise ex unless keychain_entry if keychain_entry.invalid_credentials login(user) else raise ex end end end |