<commit_before>module = angular.module('common.controllers', ['http-auth-interceptor', 'ngCookies'])

class LoginCtrl
        """
        Login a user
        """
        constructor: (@$scope, @$rootScope, @$http, @$cookies, @authService) ->
                # set authorization header if already logged in
                if @$cookies.username and @$cookies.key
                        console.debug("Already logged in.")
                        @$http.defaults.headers.common['Authorization'] = "ApiKey #{@$cookies.username}:#{@$cookies.key}"
                        @authService.loginConfirmed()
                @$scope.loginrequired = false

                # On login required
                @$scope.$on('event:auth-loginRequired', =>
                        @$scope.loginrequired = true
                        console.debug("Login required")
                )

                # On login successful
                @$scope.$on('event:auth-loginConfirmed', =>
                        console.debug("Login OK")
                        @$scope.loginrequired = false
                )

                # Add methods to scope
                @$scope.submit = this.submit

        submit: =>
                console.debug('submitting login like a mofo')
                console.debug("#{@$rootScope.CONFIG.REST_URI}account/v0/user/login/")
                @$http.post("http://carpe.local:8000/account/v0/user/login/", JSON.stringify( # XXX HARDCODED
                        username: @$scope.username
                        password: <PASSWORD>
                )).success((data) =>
                        @$cookies.username = data.username
                        @$cookies.key = data.key
                        @$http.defaults.headers.common['Authorization'] = "ApiKey #{data.username}:#{data.key}"
                        @authService.loginConfirmed()
                ).error((data) =>
                        console.debug("LoginController submit error: #{data.reason}")
                        @$scope.errorMsg = data.reason
                )

LoginCtrl.$inject = ['$scope', '$rootScope', "$http", "$cookies", "authService"]

module.controller("LoginCtrl", LoginCtrl)<commit_msg>fix auth path<commit_after>module = angular.module('common.controllers', ['http-auth-interceptor', 'ngCookies'])

class LoginCtrl
        """
        Login a user
        """
        constructor: (@$scope, @$rootScope, @$http, @$cookies, @authService) ->
                # set authorization header if already logged in
                if @$cookies.username and @$cookies.key
                        console.debug("Already logged in.")
                        @$http.defaults.headers.common['Authorization'] = "ApiKey #{@$cookies.username}:#{@$cookies.key}"
                        @authService.loginConfirmed()
                @$scope.loginrequired = false

                # On login required
                @$scope.$on('event:auth-loginRequired', =>
                        @$scope.loginrequired = true
                        console.debug("Login required")
                )

                # On login successful
                @$scope.$on('event:auth-loginConfirmed', =>
                        console.debug("Login OK")
                        @$scope.loginrequired = false
                )

                # Add methods to scope
                @$scope.submit = this.submit

        submit: =>
                console.debug('submitting login...')
                @$http.post("http://carpe.local:8000/api/account/v0/user/login/", JSON.stringify( # XXX HARDCODED
                        username: @$scope.username
                        password: <PASSWORD>
                )).success((data) =>
                        @$cookies.username = data.username
                        @$cookies.key = data.key
                        @$http.defaults.headers.common['Authorization'] = "ApiKey #{data.username}:#{data.key}"
                        @authService.loginConfirmed()
                ).error((data) =>
                        console.debug("LoginController submit error: #{data.reason}")
                        @$scope.errorMsg = data.reason
                )

LoginCtrl.$inject = ['$scope', '$rootScope', "$http", "$cookies", "authService"]

module.controller("LoginCtrl", LoginCtrl)
{'fraction_non_alphanumeric': 0.13162193698949826, 'fraction_numerical': 0.0025670945157526253, 'mean_word_length': 1.509367681498829, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 17, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '1066263', 'n_tokens_mistral': 1102, 'n_tokens_neox': 1023, 'n_words': 189}