Skip to content

Commit

Permalink
add Google Authenticator two step verification
Browse files Browse the repository at this point in the history
  • Loading branch information
tkohout committed Aug 8, 2017
1 parent b4f3073 commit 6bbc5f8
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 10 deletions.
2 changes: 1 addition & 1 deletion fastlane-plugin-firebase.gemspec
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ Gem::Specification.new do |spec|

# spec.add_dependency 'your-dependency', '~> 1.0.0'

#spec.add_development_dependency 'pry'
# spec.add_development_dependency 'pry'
spec.add_development_dependency 'bundler'
spec.add_development_dependency 'rspec'
spec.add_development_dependency 'rake'
Expand Down
18 changes: 10 additions & 8 deletions lib/fastlane/plugin/firebase/lib/api.rb
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
module Fastlane
module Firebase

class Api
class Api
class LoginError < StandardError
end

Expand All @@ -17,7 +16,7 @@ def initialize(msg, code)
require 'digest/sha1'
require 'json'
require 'cgi'

def initialize(email, password)
@agent = Mechanize.new
@base_url = "https://console.firebase.google.com"
Expand Down Expand Up @@ -57,7 +56,7 @@ def login(email, password)
elsif page.xpath("//div[@class='captcha-img']").count > 0 then
page = captcha_challenge(page)
next
elsif page.form.action.include? "/signin/challenge/" then
elsif page.form.action.include? "/signin/challenge" then
page = signin_challenge(page)
next
else
Expand Down Expand Up @@ -127,19 +126,22 @@ def signin_challenge(page)
form = page.form_with(:id => form_id)
type = (form["challengeType"] || "-1").to_i

# Two factor verification
if type == 9 then
# Two factor verification SMS
if type == 9 || type == 6 then
div = page.at("##{form_id} div")
if div != nil then
UI.important div.xpath("div[1]").text
UI.important div.xpath("div[2]").text
end

code = UI.input "Enter code G-:"
prefix = type == 9 ? " G-" : ""
code = UI.input "Enter code#{prefix}:"
form.Pin = code
page = @agent.submit(form, form.buttons.first)
return page
else
elsif type == 4 then
UI.user_error! "Google prompt is not supported as a two-step verification"
else
html = page.at("##{form_id}").to_html
UI.user_error! "Unknown challenge type \n\n#{html}"
end
Expand Down
2 changes: 1 addition & 1 deletion lib/fastlane/plugin/firebase/version.rb
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
module Fastlane
module Firebase
VERSION = "0.2.0"
VERSION = "0.2.1"
end
end

0 comments on commit 6bbc5f8

Please sign in to comment.