File tree Expand file tree Collapse file tree 1 file changed +26
-8
lines changed Expand file tree Collapse file tree 1 file changed +26
-8
lines changed Original file line number Diff line number Diff line change 1- import Cookies from 'js-cookie' ;
1+ import { Cookies } from 'typescript-cookies'
2+
3+ const cookies = new Cookies ( {
4+ path : '/' ,
5+ secure : true ,
6+ samesite : 'none' ,
7+ } )
28
39/**
4- * Redirects the user to main learn site if not AdaCore employee
10+ * Redirects the user to main learn site if not authenticated
511 */
612export function sandboxRedirect ( ) : void {
713 /* istanbul ignore next */
8- if ( ! Cookies . get ( 'AdaCore_staff' ) ) {
9- const msg = 'You have reached learn-sandbox, the learn testing site. ' +
10- 'This is reserved for testers only. You will be directed to the main ' +
11- 'learn.adacore.com site after pressing OK.' ;
12- alert ( msg ) ;
13- window . location . href = 'http://learn.adacore.com' ;
14+ const cookieName = "Learn_Sandbox_Authenticated" ;
15+ const cookieValue = cookies . get ( cookieName ) as string ;
16+ const cookieReferenceValue = "true" ;
17+
18+ if ( cookieValue != cookieReferenceValue ) {
19+ const passw = prompt ( "Enter site password:" )
20+
21+ if ( passw != "Ada" ) {
22+ const msg = 'You have reached learn-sandbox, the learn testing site. ' +
23+ 'This is reserved for testers only. You will be directed to the main ' +
24+ 'learn.adacore.com site after pressing OK.' ;
25+ alert ( msg ) ;
26+ window . location . href = 'http://learn.adacore.com' ;
27+ }
28+ else
29+ {
30+ cookies . set ( cookieName , cookieReferenceValue , { expires : 3650 } ) ;
31+ }
1432 }
1533}
You can’t perform that action at this time.
0 commit comments