Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
A
appinventor-sources
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Analytics
Analytics
Repository
Value Stream
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Commits
Open sidebar
xpstem
appinventor-sources
Commits
95df4539
Commit
95df4539
authored
Mar 27, 2019
by
Evan W. Patton
Committed by
Jeffrey Schiller
Mar 27, 2019
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Pass query string parameters through the TOS (#1634)
parent
7c04055a
Changes
5
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
69 additions
and
20 deletions
+69
-20
appinventor/appengine/src/com/google/appinventor/client/Ode.java
...ntor/appengine/src/com/google/appinventor/client/Ode.java
+23
-18
appinventor/appengine/src/com/google/appinventor/server/TosServlet.java
...pengine/src/com/google/appinventor/server/TosServlet.java
+14
-2
appinventor/appengine/war/WEB-INF/appengine-web.xml
appinventor/appengine/war/WEB-INF/appengine-web.xml
+1
-0
appinventor/appengine/war/Ya_tos_form.html
appinventor/appengine/war/Ya_tos_form.html
+1
-0
appinventor/appengine/war/js/tos.js
appinventor/appengine/war/js/tos.js
+30
-0
No files found.
appinventor/appengine/src/com/google/appinventor/client/Ode.java
View file @
95df4539
...
...
@@ -856,6 +856,27 @@ public class Ode implements EntryPoint {
topPanel
.
showUserEmail
(
user
.
getUserEmail
());
}
private
boolean
isSet
(
String
str
)
{
return
str
!=
null
&&
!
str
.
equals
(
""
);
}
private
String
makeUri
(
String
base
)
{
String
[]
params
=
new
String
[]
{
"locale"
,
"repo"
,
"galleryId"
};
String
separator
=
"?"
;
StringBuilder
sb
=
new
StringBuilder
(
base
);
for
(
String
param
:
params
)
{
String
value
=
Window
.
Location
.
getParameter
(
param
);
if
(
isSet
(
value
))
{
sb
.
append
(
separator
);
sb
.
append
(
param
);
sb
.
append
(
"="
);
sb
.
append
(
value
);
separator
=
"&"
;
}
}
return
sb
.
toString
();
}
@Override
public
void
onFailure
(
Throwable
caught
)
{
if
(
caught
instanceof
StatusCodeException
)
{
...
...
@@ -870,26 +891,10 @@ public class Ode implements EntryPoint {
return
;
case
Response
.
SC_FORBIDDEN
:
// forbidden => need tos accept
Window
.
open
(
"/"
+
ServerLayout
.
YA_TOS_FORM
,
"_self"
,
null
);
Window
.
open
(
makeUri
(
"/"
+
ServerLayout
.
YA_TOS_FORM
)
,
"_self"
,
null
);
return
;
case
Response
.
SC_PRECONDITION_FAILED
:
String
locale
=
Window
.
Location
.
getParameter
(
"locale"
);
String
repo
=
Window
.
Location
.
getParameter
(
"repo"
);
galleryId
=
Window
.
Location
.
getParameter
(
"galleryId"
);
String
separator
=
"?"
;
String
uri
=
"/login/"
;
if
(
locale
!=
null
&&
!
locale
.
equals
(
""
))
{
uri
+=
separator
+
"locale="
+
locale
;
separator
=
"&"
;
}
if
(
repo
!=
null
&&
!
repo
.
equals
(
""
))
{
uri
+=
separator
+
"repo="
+
repo
;
separator
=
"&"
;
}
if
(
galleryId
!=
null
&&
!
galleryId
.
equals
(
""
))
{
uri
+=
separator
+
"galleryId="
+
galleryId
;
}
Window
.
Location
.
replace
(
uri
);
Window
.
Location
.
replace
(
makeUri
(
"/login/"
));
return
;
// likely not reached
}
}
...
...
appinventor/appengine/src/com/google/appinventor/server/TosServlet.java
View file @
95df4539
// -*- mode: java; c-basic-offset: 2; -*-
// Copyright 2009-2011 Google, All Rights reserved
// Copyright 2011-201
2
MIT, All rights reserved
// Copyright 2011-201
9
MIT, All rights reserved
// Released under the Apache License, Version 2.0
// http://www.apache.org/licenses/LICENSE-2.0
...
...
@@ -9,6 +9,7 @@ package com.google.appinventor.server;
import
com.google.appinventor.server.flags.Flag
;
import
com.google.appinventor.server.storage.StorageIo
;
import
com.google.appinventor.server.storage.StorageIoInstanceHolder
;
import
com.google.appinventor.server.util.UriBuilder
;
import
java.io.IOException
;
import
java.util.logging.Logger
;
...
...
@@ -35,6 +36,8 @@ public class TosServlet extends OdeServlet {
private
static
final
Flag
<
String
>
initialRedirectionUrl
=
Flag
.
createFlag
(
"initial.redirection.url"
,
"/"
);
private
static
final
String
[]
PARAMS
=
new
String
[]
{
"locale"
,
"repo"
,
"galleryId"
};
@Override
public
void
doPost
(
HttpServletRequest
req
,
HttpServletResponse
resp
)
throws
IOException
{
...
...
@@ -42,6 +45,15 @@ public class TosServlet extends OdeServlet {
storageIo
.
setTosAccepted
(
LocalUser
.
getInstance
().
getUserId
());
// Redirect the user to the initialRedirectionUrl (the 'About' page, by default).
resp
.
sendRedirect
(
initialRedirectionUrl
.
get
());
// Also include parameters passed from the TOS form.
UriBuilder
builder
=
new
UriBuilder
(
initialRedirectionUrl
.
get
());
for
(
String
param
:
PARAMS
)
{
String
value
=
req
.
getParameter
(
param
);
if
(
value
!=
null
&&
!
value
.
isEmpty
())
{
builder
.
add
(
param
,
value
);
}
}
resp
.
sendRedirect
(
builder
.
build
());
}
}
appinventor/appengine/war/WEB-INF/appengine-web.xml
View file @
95df4539
...
...
@@ -15,6 +15,7 @@
<include
path=
"/static/**"
expiration=
"1d"
/>
<include
path=
"/websiteassets/**"
expiration=
"10s"
/>
<include
path=
"/images/*"
expiration=
"365d"
/>
<include
path=
"/js/*"
/>
<include
path=
"/Ya_tos_form.html"
expiration=
"1d"
/>
<include
path=
"/favicon.ico"
expiration=
"365d"
/>
<include
path=
"/gwt.css"
expiration=
"1d"
/>
...
...
appinventor/appengine/war/Ya_tos_form.html
View file @
95df4539
...
...
@@ -3,6 +3,7 @@
<title>
Terms of Service
</title>
<link
type=
"text/css"
rel=
"stylesheet"
href=
"Ya.css"
>
<link
href=
'http://fonts.googleapis.com/css?family=Roboto'
rel=
'stylesheet'
type=
'text/css'
>
<script
src=
"js/tos.js"
></script>
</head>
<body>
...
...
appinventor/appengine/war/js/tos.js
0 → 100644
View file @
95df4539
// -*- mode: javascript; js-indent-level: 2; -*-
// Copyright © 2019 Massachusetts Institute of Technology, All rights reserved.
// Released under the Apache License, Version 2.0
// http://www.apache.org/licenses/LICENSE-2.0
/**
* Inspects the query string for any key=value pairs and adds hidden
* input elements to the TOS form so that they can be passed through
* when the user accepts the terms.
*/
function
setupForm
()
{
var
parts
=
window
.
location
.
href
.
split
(
'
?
'
);
if
(
parts
.
length
===
1
)
return
;
var
queryString
=
parts
[
1
];
parts
=
queryString
.
split
(
'
&
'
);
if
(
parts
.
length
===
0
)
return
;
var
form
=
document
.
forms
[
0
];
for
(
var
i
=
0
;
i
<
parts
.
length
;
i
++
)
{
var
keyval
=
parts
[
i
].
split
(
'
=
'
),
key
=
keyval
[
0
],
val
=
keyval
[
1
],
input
=
document
.
createElement
(
'
input
'
);
input
.
setAttribute
(
'
type
'
,
'
hidden
'
);
input
.
setAttribute
(
'
name
'
,
key
);
input
.
setAttribute
(
'
value
'
,
val
);
form
.
appendChild
(
input
);
}
}
window
.
onload
=
setupForm
;
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment