@@ -8,6 +8,17 @@ $(document).ready(function(){
8
8
var formSubmitted = urlParams . get ( 'form_submitted' ) ;
9
9
var formType = urlParams . get ( 'form_type' ) ;
10
10
11
+ var userAuthenticated = urlParams . get ( 'auth' ) ;
12
+
13
+ var current_search_location = window . 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
+
11
22
if ( formSubmitted === 'True' ) {
12
23
var message = '' ;
13
24
if ( formType === 'login' ) {
@@ -30,6 +41,13 @@ $(document).ready(function(){
30
41
$ ( '.important-message' ) . text ( message ) ;
31
42
$ ( '.form-submission-popup' ) . css ( 'display' , 'block' ) ;
32
43
}
44
+ else if ( userAuthenticated === 'false' ) {
45
+ $ ( '.important-message' ) . text (
46
+ 'You tried to access a webpage, which is available to only' +
47
+ ' authenticated users. Please join the community or Login(if' +
48
+ ' already a member of organization)' ) ;
49
+ $ ( '.form-submission-popup' ) . css ( 'display' , 'block' ) ;
50
+ }
33
51
34
52
function activate_dropdown ( ) {
35
53
if ( $ ( 'nav' ) . width ( ) < 992 ) {
@@ -44,7 +62,7 @@ $(document).ready(function(){
44
62
45
63
function check_user_authenticated_or_not ( ) {
46
64
if ( Cookies . get ( 'authenticated' ) ) {
47
- modify_html_elements ( 'none' , 'none' , 'block' , 'block' ) ;
65
+ modify_html_elements ( 'none' , 'none' , 'block' , 'block' , 'block' ) ;
48
66
}
49
67
}
50
68
@@ -60,11 +78,12 @@ $(document).ready(function(){
60
78
61
79
function modify_html_elements ( popup_form_display , login_option_display ,
62
80
logout__option_display ,
63
- form_option_display ) {
81
+ form_option_display , teams_option_display ) {
64
82
$ ( '.form-popup' ) . css ( 'display' , popup_form_display ) ;
65
83
login_user_el . css ( 'display' , login_option_display ) ;
66
84
logout_user_el . css ( 'display' , logout__option_display ) ;
67
85
$ ( '.forms-dropdown-option' ) . css ( 'display' , form_option_display ) ;
86
+ $ ( '.teams-dropdown-option' ) . css ( 'display' , teams_option_display ) ;
68
87
}
69
88
70
89
function manipulate_web_page_data ( oauth_provider , http_response_text ) {
@@ -73,7 +92,7 @@ $(document).ready(function(){
73
92
// Cookies expires in 3 days
74
93
Cookies . set ( 'authenticated' , true , { expires : 3 } ) ;
75
94
Cookies . set ( 'username' , json_data . user , { expires : 3 } ) ;
76
- modify_html_elements ( 'none' , 'none' , 'block' , 'block' ) ;
95
+ modify_html_elements ( 'none' , 'none' , 'block' , 'block' , 'block' ) ;
77
96
}
78
97
else {
79
98
display_error_message ( oauth_provider , json_data . message ) ;
@@ -144,7 +163,7 @@ $(document).ready(function(){
144
163
logout_user_el . click ( function ( ) {
145
164
Cookies . remove ( 'authenticated' ) ;
146
165
Cookies . remove ( 'username' ) ;
147
- modify_html_elements ( 'none' , 'block' , 'none' , 'none' ) ;
166
+ modify_html_elements ( 'none' , 'block' , 'none' , 'none' , 'none' ) ;
148
167
} ) ;
149
168
150
169
$ ( '.login-with-github' ) . click ( function ( e ) {
0 commit comments