<commit_before>Template.loginServices.helpers
	hasLoginServices: ->
		return Accounts.oauth.serviceNames()?.length > 0

	loginService: ->
		services = []

		authServices = Accounts.oauth.serviceNames()

		authServices.sort()

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

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

		return services

Template.loginServices.events
	'click .external-login': ->
		return unless this.service?

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

		serviceConfig = {}

		if this.service is 'github'
			serviceConfig.requestPermissions = ['user']

		Meteor[loginWithService] serviceConfig, (error) ->
			if error?.error is 'github-no-public-email'
				alert "You don't have any email as public email in your GitHub account"
				return

			console.log error
			if error
				toastr.error error.message<commit_msg>Removed github request permissions scope (this was requesting full read/write on user info); No scope means read-only.<commit_after>Template.loginServices.helpers
	hasLoginServices: ->
		return Accounts.oauth.serviceNames()?.length > 0

	loginService: ->
		services = []

		authServices = Accounts.oauth.serviceNames()

		authServices.sort()

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

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

		return services

Template.loginServices.events
	'click .external-login': ->
		return unless this.service?

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

		serviceConfig = {}

		Meteor[loginWithService] serviceConfig, (error) ->
			if error?.error is 'github-no-public-email'
				alert "You don't have any email as public email in your GitHub account"
				return

			console.log error
			if error
				toastr.error error.message
{'fraction_non_alphanumeric': 0.09581086686022397, 'fraction_numerical': 0.0008295313148071339, 'mean_word_length': 3.4584103512014788, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 15, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 2, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '4803861', 'n_tokens_mistral': 879, 'n_tokens_neox': 685, 'n_words': 191}