<commit_before>Template.loginServices.helpers
	loginService: ->
		services = []

		authServices = _.pluck ServiceConfiguration.configurations.find({}, { service: 1 }).fetch(), 'service'

		authServices.sort()

		authServices.forEach (service) ->
			switch service
				when 'meteor-developer'
					serviceName = 'Meteor'
					icon = 'meteor'
				when 'github'
					serviceName = 'GitHub'
					icon = 'github-circled'
				else
					serviceName = _.capitalize service
					icon = service

			services.push
				service: service
				displayName: serviceName
				icon: icon

		return services

Template.loginServices.events
	'click .external-login': (e, t)->
		return unless this.service?

		loadingIcon = $(e.currentTarget).find('.loading-icon')
		serviceIcon = $(e.currentTarget).find('.service-icon')

		loadingIcon.removeClass 'hidden'
		serviceIcon.addClass 'hidden'

		# login with native facebook app
		if Meteor.isCordova and this.service is 'facebook'
			Meteor.loginWithFacebookCordova {}, (error) ->
				loadingIcon.addClass 'hidden'
				serviceIcon.removeClass 'hidden'

				if error
					console.log error
					toastr.error error.message
					return

				FlowRouter.go 'index'
		else
			loginWithService = "loginWith" + (if this.service is 'meteor-developer' then 'MeteorDeveloperAccount' else _.capitalize(this.service))

			serviceConfig = {}

			Meteor[loginWithService] serviceConfig, (error) ->
				loadingIcon.addClass 'hidden'
				serviceIcon.removeClass 'hidden'

				if error?.error is 'github-no-public-email'
					alert t("github_no_public_email")
					return

				if error
					console.log error
					toastr.error error.message
					return
				FlowRouter.go 'index'<commit_msg>Try to improve logs of errors in android app<commit_after>Template.loginServices.helpers
	loginService: ->
		services = []

		authServices = _.pluck ServiceConfiguration.configurations.find({}, { service: 1 }).fetch(), 'service'

		authServices.sort()

		authServices.forEach (service) ->
			switch service
				when 'meteor-developer'
					serviceName = 'Meteor'
					icon = 'meteor'
				when 'github'
					serviceName = 'GitHub'
					icon = 'github-circled'
				else
					serviceName = _.capitalize service
					icon = service

			services.push
				service: service
				displayName: serviceName
				icon: icon

		return services

Template.loginServices.events
	'click .external-login': (e, t)->
		return unless this.service?

		loadingIcon = $(e.currentTarget).find('.loading-icon')
		serviceIcon = $(e.currentTarget).find('.service-icon')

		loadingIcon.removeClass 'hidden'
		serviceIcon.addClass 'hidden'

		# login with native facebook app
		if Meteor.isCordova and this.service is 'facebook'
			Meteor.loginWithFacebookCordova {}, (error) ->
				loadingIcon.addClass 'hidden'
				serviceIcon.removeClass 'hidden'

				if error
					console.log JSON.stringify(error), error.message
					toastr.error error.message
					return

				FlowRouter.go 'index'
		else
			loginWithService = "loginWith" + (if this.service is 'meteor-developer' then 'MeteorDeveloperAccount' else _.capitalize(this.service))

			serviceConfig = {}

			Meteor[loginWithService] serviceConfig, (error) ->
				loadingIcon.addClass 'hidden'
				serviceIcon.removeClass 'hidden'

				if error?.error is 'github-no-public-email'
					alert t("github_no_public_email")
					return

				if error
					console.log JSON.stringify(error), error.message
					toastr.error error.message
					return
				FlowRouter.go 'index'
{'fraction_non_alphanumeric': 0.10616929698708752, 'fraction_numerical': 0.0005738880918220947, 'mean_word_length': 3.429479034307497, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 13, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 4, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '1988975', 'n_tokens_mistral': 1313, 'n_tokens_neox': 1006, 'n_words': 247}