Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Menu
Open sidebar
dmccormi
project-base
Commits
0e38fae4
Commit
0e38fae4
authored
Jul 22, 2015
by
Will Billingsley
Browse files
Added skeleton of the captcha app for the tutorial
parent
bc4cbeaf
Changes
6
Hide whitespace changes
Inline
Side-by-side
app/controllers/Application.java
View file @
0e38fae4
...
...
@@ -6,16 +6,12 @@ import play.mvc.Result;
public
class
Application
extends
Controller
{
public
static
Result
encrypt
(
String
pw
)
{
return
ok
(
views
.
html
.
application
.
encrypted
.
render
(
BCryptExample
.
encrypt
(
pw
)));
}
public
static
Result
matches
(
String
pw
)
{
return
ok
(
views
.
html
.
application
.
matches
.
render
(
BCryptExample
.
matchesLastEncrypted
(
pw
)));
public
static
Result
index
()
{
return
internalServerError
(
"Not implemented yet..."
);
}
public
static
Result
index
()
{
return
ok
(
views
.
html
.
application
.
index
.
render
()
);
public
static
Result
matches
()
{
return
internalServerError
(
"Not implemented yet..."
);
}
}
app/model/Captcha.java
View file @
0e38fae4
...
...
@@ -6,7 +6,11 @@ public class Captcha {
* URLs of photos the user should select
*/
public
static
String
[]
yesPhotos
=
{
"http://assets.dogtime.com/breed/profile/image/4d3771f10106195669001f8c/beagle.jpg"
,
"https://gdkennel.files.wordpress.com/2013/09/010.jpg"
,
"http://www.perros2.com/wp-content/uploads/2012/06/ddd.jpg"
,
"http://dogobedienceadvice.com/images/beagle_training.jpg"
,
"http://www.swish-swash.co.uk/images/beagle/beagles.jpg"
};
...
...
@@ -14,7 +18,11 @@ public class Captcha {
* URLs of photos the user should not select
*/
public
static
String
[]
noPhotos
=
{
"http://www.pets4homes.co.uk/images/articles/1265/large/ten-reasons-why-dogs-make-better-pets-than-cats-52bc3172b4816.jpg"
,
"http://www.adweek.com/files/imagecache/node-blog/sa_article/dog_image_0.jpg"
,
"http://7-themes.com/data_images/out/36/6891162-dogs.jpg"
,
"http://www.boxer-dog.org/sites/default/files/imagecache/500_width/ruby2.jpg"
,
"http://www.imagepuppy.com/resized/762ce6cb8241c08d73ec9304b42f6d5f.jpg"
};
/**
...
...
app/views/application/encrypted.scala.html
deleted
100644 → 0
View file @
bc4cbeaf
@(hash: String)
<!DOCTYPE html>
<html>
<head
lang=
"en"
>
<meta
charset=
"UTF-8"
>
<title></title>
</head>
<body>
<h1>
Here's that encrypted with a new salt:
</h1>
<p>
@hash
</p>
<h2>
Check a password matches the last one
</h2>
<form
action=
"matches"
>
<input
type=
"password"
name=
"pw"
/>
<button
type=
"submit"
>
Check
</button>
</form>
</body>
</html>
\ No newline at end of file
app/views/application/index.scala.html
View file @
0e38fae4
@()
@(
indexes:Array[Int]
)
<!DOCTYPE html>
<html>
<head
lang=
"en"
>
<meta
name=
"referrer"
content=
"no-referrer"
>
<meta
charset=
"UTF-8"
>
<title></title>
</head>
<body>
<h1>
Encrypt a password:
</h1>
<form
action=
"encrypt"
>
<input
type=
"password"
name=
"pw"
/>
<h1>
Tick all the beagles:
</h1>
<!-- TODO: This form probably has the wrong method... -->
<form
action=
"captcha"
>
<!--
TODO: For each index in the array, show a checkbox with the value of the index, and the relevant img
-->
<button
type=
"submit"
>
Submit
</button>
</form>
...
...
app/views/application/matches.scala.html
View file @
0e38fae4
@(
matches: Boolean
)
@(
beagles: Int, found: Int
)
<!DOCTYPE html>
<html>
...
...
@@ -8,17 +8,7 @@
</head>
<body>
@if(matches) {
<h1>
Yes, it matched!
</h1>
} else {
<h2>
Noo, that wasn't the password
</h2>
}
<h2>
Check a password matches the last one
</h2>
<form
action=
"matches"
>
<input
type=
"password"
name=
"pw"
/>
<button
type=
"submit"
>
Check
</button>
</form>
You found @found of @beagles beagles.
</body>
</html>
\ No newline at end of file
conf/routes
View file @
0e38fae4
...
...
@@ -2,10 +2,8 @@
# This file defines all application routes (Higher priority routes first)
# ~~~~
# Home page
GET / controllers.Application.index()
GET /encrypt controllers.Application.encrypt(pw)
GET /matches controllers.Application.matches(pw)
POST /matches controllers.Application.matches()
# Map static resources from the /public folder to the /assets URL path
GET /assets/*file controllers.Assets.versioned(path="/public", file: Asset)
\ No newline at end of file
Write
Preview
Supports
Markdown
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