@@ -7,6 +7,18 @@ $(document).ready(function(){
77 var urlParams = new URLSearchParams ( location . search ) ;
88 var formSubmitted = urlParams . get ( 'form_submitted' ) ;
99 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+
1022 if ( formSubmitted === 'True' ) {
1123 var message = '' ;
1224 if ( formType === 'login' ) {
@@ -29,6 +41,13 @@ $(document).ready(function(){
2941 $ ( '.important-message' ) . text ( message ) ;
3042 $ ( '.form-submission-popup' ) . css ( 'display' , 'block' ) ;
3143 }
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+ }
3251
3352 function activate_dropdown ( ) {
3453 if ( $ ( 'nav' ) . width ( ) < 992 ) {
@@ -43,7 +62,8 @@ $(document).ready(function(){
4362
4463 function check_user_authenticated_or_not ( ) {
4564 if ( Cookies . get ( 'authenticated' ) ) {
46- modify_html_elements ( 'none' , 'none' , 'block' , 'block' , 'block' ) ;
65+ modify_html_elements ( 'none' , 'none' , 'block' , 'block' , 'block' ,
66+ 'block' ) ;
4767 }
4868 }
4969
@@ -60,12 +80,13 @@ $(document).ready(function(){
6080 function modify_html_elements ( popup_form_display , login_option_display ,
6181 profile_option_display ,
6282 logout__option_display ,
63- form_option_display ) {
83+ form_option_display , teams_option_display ) {
6484 $ ( '.form-popup' ) . css ( 'display' , popup_form_display ) ;
6585 login_user_el . css ( 'display' , login_option_display ) ;
6686 $ ( '.user-profile' ) . css ( 'display' , profile_option_display ) ;
6787 logout_user_el . css ( 'display' , logout__option_display ) ;
6888 $ ( '.forms-dropdown-option' ) . css ( 'display' , form_option_display ) ;
89+ $ ( '.teams-dropdown-option' . css ( 'display' , teams_option_display ) ) ;
6990 }
7091
7192 function manipulate_web_page_data ( oauth_provider , http_response_text ) {
@@ -74,7 +95,8 @@ $(document).ready(function(){
7495 // Cookies expires in 3 days
7596 Cookies . set ( 'authenticated' , true , { expires : 3 } ) ;
7697 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' ) ;
78100 }
79101 else {
80102 display_error_message ( oauth_provider , json_data . message ) ;
@@ -145,7 +167,7 @@ $(document).ready(function(){
145167 logout_user_el . click ( function ( ) {
146168 Cookies . remove ( 'authenticated' ) ;
147169 Cookies . remove ( 'username' ) ;
148- modify_html_elements ( 'none' , 'block' , 'none' , 'none' , 'none' ) ;
170+ modify_html_elements ( 'none' , 'block' , 'none' , 'none' , 'none' , 'none' ) ;
149171 } ) ;
150172
151173 $ ( '.login-with-github' ) . click ( function ( e ) {
0 commit comments