@@ -33,73 +33,75 @@ var application = angular.module('loginSystem', []);
3333
3434application . config ( [ '$interpolateProvider' ,
3535
36- function ( $interpolateProvider ) {
36+ function ( $interpolateProvider ) {
3737 $interpolateProvider . startSymbol ( '{$' ) ;
3838 $interpolateProvider . endSymbol ( '$}' ) ;
3939 }
4040] ) ;
4141
42- application . controller ( 'loginSystem' , function ( $scope , $http , $window ) {
42+ application . controller ( 'loginSystem' , function ( $scope , $http , $window ) {
4343
44+ $scope . verifyCode = true ;
4445
45- $scope . verifyLoginCredentials = function ( ) {
46+ $scope . verifyLoginCredentials = function ( ) {
4647
47- $ ( "#verifyingLogin" ) . show ( ) ;
48+ $ ( "#verifyingLogin" ) . show ( ) ;
4849
4950
50- var username = $scope . username ;
51- var password = $scope . password ;
52- var languageSelection = $scope . languageSelection ;
51+ var username = $scope . username ;
52+ var password = $scope . password ;
53+ var languageSelection = $scope . languageSelection ;
5354
5455
55- url = "/verifyLogin" ;
56+ url = "/verifyLogin" ;
5657
57- var data = {
58- username : username ,
59- password : password ,
60- languageSelection :languageSelection ,
61- } ;
62-
63- var config = {
64- headers : {
65- 'X-CSRFToken' : getCookie ( 'csrftoken' )
66- }
67- } ;
68-
69- $http . post ( url , data , config ) . then ( ListInitialData , cantLoadInitialData ) ;
58+ var data = {
59+ username : username ,
60+ password : password ,
61+ languageSelection : languageSelection ,
62+ twofa : $scope . twofa
63+ } ;
7064
65+ var config = {
66+ headers : {
67+ 'X-CSRFToken' : getCookie ( 'csrftoken' )
68+ }
69+ } ;
7170
72- function ListInitialData ( response ) {
71+ $http . post ( url , data , config ) . then ( ListInitialData , cantLoadInitialData ) ;
7372
74- if ( response . data . loginStatus === 0 )
75- {
76- $scope . errorMessage = response . data . error_message ;
77- $ ( "#loginFailed" ) . fadeIn ( ) ;
78- }
79- else {
80- $ ( "#loginFailed" ) . hide ( ) ;
81- $window . location . href = '/base/' ;
82- }
8373
74+ function ListInitialData ( response ) {
8475
76+ if ( response . data . loginStatus === 0 ) {
77+ $scope . errorMessage = response . data . error_message ;
78+ $ ( "#loginFailed" ) . fadeIn ( ) ;
79+ } else if ( response . data . loginStatus === 2 ) {
80+ $scope . verifyCode = false ;
81+ }
82+ else {
83+ $ ( "#loginFailed" ) . hide ( ) ;
84+ $window . location . href = '/base/' ;
85+ }
8586
86- $ ( "#verifyingLogin" ) . hide ( ) ;
87- }
88- function cantLoadInitialData ( response ) { }
8987
88+ $ ( "#verifyingLogin" ) . hide ( ) ;
89+ }
9090
91+ function cantLoadInitialData ( response ) {
92+ }
9193
9294
93- } ;
95+ } ;
9496
95- $scope . initiateLogin = function ( $event ) {
96- var keyCode = $event . which || $event . keyCode ;
97- if ( keyCode === 13 ) {
98- $scope . verifyLoginCredentials ( ) ;
97+ $scope . initiateLogin = function ( $event ) {
98+ var keyCode = $event . which || $event . keyCode ;
99+ if ( keyCode === 13 ) {
100+ $scope . verifyLoginCredentials ( ) ;
99101
100- }
102+ }
101103
102- } ;
104+ } ;
103105
104106
105107} ) ;
0 commit comments