Commit 0e38fae4 authored by Will Billingsley's avatar Will Billingsley
Browse files

Added skeleton of the captcha app for the tutorial

parent bc4cbeaf
......@@ -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...");
}
}
......@@ -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"
};
/**
......
@(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
@()
@(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>
......
@(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
......@@ -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
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment