@@ -7,6 +7,18 @@ $(document).ready(function(){
7
7
var urlParams = new URLSearchParams ( location . search ) ;
8
8
var formSubmitted = urlParams . get ( 'form_submitted' ) ;
9
9
var formType = urlParams . get ( 'form_type' ) ;
10
+ var userAuthenticated = urlParams . get ( 'auth' ) ;
11
+
12
+ var current_search_location = window . location ;
13
+ console . log ( current_search_location ) ;
14
+ if ( current_search_location . toString ( ) . search ( 'teams' ) > 0 ) {
15
+ var is_authenticated = Cookies . set ( 'authenticated' ) ;
16
+ var username = Cookies . set ( 'username' ) ;
17
+ if ( is_authenticated !== true && username === undefined ) {
18
+ window . location = window . location . origin + '?auth=false' ;
19
+ }
20
+ }
21
+
10
22
if ( formSubmitted === 'True' ) {
11
23
var message = '' ;
12
24
if ( formType === 'login' ) {
@@ -25,7 +37,13 @@ $(document).ready(function(){
25
37
$ ( '.important-message' ) . text ( message ) ;
26
38
$ ( '.form-submission-popup' ) . css ( 'display' , 'block' ) ;
27
39
}
28
-
40
+ else if ( userAuthenticated === 'false' ) {
41
+ $ ( '.important-message' ) . text (
42
+ 'You tried to access a webpage, which is available to only' +
43
+ ' authenticated users. Please join the community or Login(if' +
44
+ ' already a member of organization)' ) ;
45
+ $ ( '.form-submission-popup' ) . css ( 'display' , 'block' ) ;
46
+ }
29
47
30
48
31
49
function activate_dropdown ( ) {
@@ -41,7 +59,7 @@ $(document).ready(function(){
41
59
42
60
function check_user_authenticated_or_not ( ) {
43
61
if ( Cookies . get ( 'authenticated' ) ) {
44
- modify_html_elements ( 'none' , 'none' , 'block' , 'block' , 'block' ) ;
62
+ modify_html_elements ( 'none' , 'none' , 'block' , 'block' , 'block' , 'block' ) ;
45
63
}
46
64
}
47
65
@@ -58,20 +76,21 @@ $(document).ready(function(){
58
76
function modify_html_elements ( popup_form_display , login_option_display ,
59
77
profile_option_display ,
60
78
logout__option_display ,
61
- form_option_display ) {
79
+ form_option_display , teams_option_display ) {
62
80
$ ( '.form-popup' ) . css ( 'display' , popup_form_display ) ;
63
81
login_user_el . css ( 'display' , login_option_display ) ;
64
82
$ ( '.user-profile' ) . css ( 'display' , profile_option_display ) ;
65
83
logout_user_el . css ( 'display' , logout__option_display ) ;
66
84
$ ( '.forms-dropdown-option' ) . css ( 'display' , form_option_display ) ;
85
+ $ ( '.teams-dropdown-option' . css ( 'display' , teams_option_display ) ) ;
67
86
}
68
87
69
88
function manipulate_web_page_data ( oauth_provider , http_response_text ) {
70
89
var json_data = JSON . parse ( http_response_text ) ;
71
90
if ( json_data . valid ) {
72
91
Cookies . set ( 'authenticated' , true ) ;
73
92
Cookies . set ( 'username' , json_data . user ) ;
74
- modify_html_elements ( 'none' , 'none' , 'block' , 'block' , 'block' ) ;
93
+ modify_html_elements ( 'none' , 'none' , 'block' , 'block' , 'block' , 'block' ) ;
75
94
}
76
95
else {
77
96
display_error_message ( oauth_provider , json_data . message ) ;
@@ -136,7 +155,7 @@ $(document).ready(function(){
136
155
logout_user_el . click ( function ( ) {
137
156
Cookies . remove ( 'authenticated' ) ;
138
157
Cookies . remove ( 'username' ) ;
139
- modify_html_elements ( 'none' , 'block' , 'none' , 'none' , 'none' ) ;
158
+ modify_html_elements ( 'none' , 'block' , 'none' , 'none' , 'none' , 'none' ) ;
140
159
} ) ;
141
160
142
161
$ ( '.login-with-github' ) . click ( function ( e ) {
0 commit comments