@@ -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' ) {
@@ -29,6 +41,13 @@ $(document).ready(function(){
29
41
$ ( '.important-message' ) . text ( message ) ;
30
42
$ ( '.form-submission-popup' ) . css ( 'display' , 'block' ) ;
31
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
+ }
32
51
33
52
function activate_dropdown ( ) {
34
53
if ( $ ( 'nav' ) . width ( ) < 992 ) {
@@ -43,7 +62,8 @@ $(document).ready(function(){
43
62
44
63
function check_user_authenticated_or_not ( ) {
45
64
if ( Cookies . get ( 'authenticated' ) ) {
46
- modify_html_elements ( 'none' , 'none' , 'block' , 'block' , 'block' ) ;
65
+ modify_html_elements ( 'none' , 'none' , 'block' , 'block' , 'block' ,
66
+ 'block' ) ;
47
67
}
48
68
}
49
69
@@ -60,12 +80,13 @@ $(document).ready(function(){
60
80
function modify_html_elements ( popup_form_display , login_option_display ,
61
81
profile_option_display ,
62
82
logout__option_display ,
63
- form_option_display ) {
83
+ form_option_display , teams_option_display ) {
64
84
$ ( '.form-popup' ) . css ( 'display' , popup_form_display ) ;
65
85
login_user_el . css ( 'display' , login_option_display ) ;
66
86
$ ( '.user-profile' ) . css ( 'display' , profile_option_display ) ;
67
87
logout_user_el . css ( 'display' , logout__option_display ) ;
68
88
$ ( '.forms-dropdown-option' ) . css ( 'display' , form_option_display ) ;
89
+ $ ( '.teams-dropdown-option' . css ( 'display' , teams_option_display ) ) ;
69
90
}
70
91
71
92
function manipulate_web_page_data ( oauth_provider , http_response_text ) {
@@ -74,7 +95,8 @@ $(document).ready(function(){
74
95
// Cookies expires in 3 days
75
96
Cookies . set ( 'authenticated' , true , { expires : 3 } ) ;
76
97
Cookies . set ( 'username' , json_data . user , { expires : 3 } ) ;
77
- modify_html_elements ( 'none' , 'none' , 'block' , 'block' , 'block' ) ;
98
+ modify_html_elements ( 'none' , 'none' , 'block' , 'block' , 'block' ,
99
+ 'block' ) ;
78
100
}
79
101
else {
80
102
display_error_message ( oauth_provider , json_data . message ) ;
@@ -145,7 +167,7 @@ $(document).ready(function(){
145
167
logout_user_el . click ( function ( ) {
146
168
Cookies . remove ( 'authenticated' ) ;
147
169
Cookies . remove ( 'username' ) ;
148
- modify_html_elements ( 'none' , 'block' , 'none' , 'none' , 'none' ) ;
170
+ modify_html_elements ( 'none' , 'block' , 'none' , 'none' , 'none' , 'none' ) ;
149
171
} ) ;
150
172
151
173
$ ( '.login-with-github' ) . click ( function ( e ) {
0 commit comments