@@ -33,73 +33,75 @@ var application = angular.module('loginSystem', []);
33
33
34
34
application . config ( [ '$interpolateProvider' ,
35
35
36
- function ( $interpolateProvider ) {
36
+ function ( $interpolateProvider ) {
37
37
$interpolateProvider . startSymbol ( '{$' ) ;
38
38
$interpolateProvider . endSymbol ( '$}' ) ;
39
39
}
40
40
] ) ;
41
41
42
- application . controller ( 'loginSystem' , function ( $scope , $http , $window ) {
42
+ application . controller ( 'loginSystem' , function ( $scope , $http , $window ) {
43
43
44
+ $scope . verifyCode = true ;
44
45
45
- $scope . verifyLoginCredentials = function ( ) {
46
+ $scope . verifyLoginCredentials = function ( ) {
46
47
47
- $ ( "#verifyingLogin" ) . show ( ) ;
48
+ $ ( "#verifyingLogin" ) . show ( ) ;
48
49
49
50
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 ;
53
54
54
55
55
- url = "/verifyLogin" ;
56
+ url = "/verifyLogin" ;
56
57
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
+ } ;
70
64
65
+ var config = {
66
+ headers : {
67
+ 'X-CSRFToken' : getCookie ( 'csrftoken' )
68
+ }
69
+ } ;
71
70
72
- function ListInitialData ( response ) {
71
+ $http . post ( url , data , config ) . then ( ListInitialData , cantLoadInitialData ) ;
73
72
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
- }
83
73
74
+ function ListInitialData ( response ) {
84
75
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
+ }
85
86
86
- $ ( "#verifyingLogin" ) . hide ( ) ;
87
- }
88
- function cantLoadInitialData ( response ) { }
89
87
88
+ $ ( "#verifyingLogin" ) . hide ( ) ;
89
+ }
90
90
91
+ function cantLoadInitialData ( response ) {
92
+ }
91
93
92
94
93
- } ;
95
+ } ;
94
96
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 ( ) ;
99
101
100
- }
102
+ }
101
103
102
- } ;
104
+ } ;
103
105
104
106
105
107
} ) ;
0 commit comments