summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--gentoobrowse/emails/signup.xslt23
-rw-r--r--gentoobrowse/emails/welcome.xml16
-rw-r--r--gentoobrowse/present/confirm.xml13
-rw-r--r--gentoobrowse/request/doconfirm.xml35
-rw-r--r--gentoobrowse/request/dologin.xml12
-rw-r--r--gentoobrowse/request/dosignup.xml48
6 files changed, 147 insertions, 0 deletions
diff --git a/gentoobrowse/emails/signup.xslt b/gentoobrowse/emails/signup.xslt
new file mode 100644
index 0000000..914784d
--- /dev/null
+++ b/gentoobrowse/emails/signup.xslt
@@ -0,0 +1,23 @@
+<?xml version="1.0" encoding="UTF-8" ?>
+<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
+ xmlns:project2="http://project2.randomdan.homeip.net/" exclude-result-prefixes="project2" >
+ <xsl:output encoding="utf-8" method="html" media-type="text/html" indent="yes"
+ doctype-system="http://www.w3.org/TR/html4/loose.dtd"
+ doctype-public="-//W3C//DTD HTML 4.01 Transitional//EN" />
+ <xsl:template match="/signup">
+ <html>
+ <head>
+ <title>Welcome to Gentoo Browse</title>
+ </head>
+ <body>
+ <p>Welcome to Gentoo Browse!</p>
+ <p>
+ Click <a><xsl:attribute name="href">http://<xsl:value-of select="/signup/project2:servername" />/confirm?verifyguid=<xsl:value-of select="/signup/verifyguids/verifyguid/guid" />
+ </xsl:attribute>this link</a> to confirm your account.
+ </p>
+ <p>Or alternatively, copy and paste this code into the confirmation page: <xsl:value-of select="/signup/verifyguids/verifyguid/guid" /></p>
+ </body>
+ </html>
+ </xsl:template>
+</xsl:stylesheet>
+
diff --git a/gentoobrowse/emails/welcome.xml b/gentoobrowse/emails/welcome.xml
new file mode 100644
index 0000000..09d2c3d
--- /dev/null
+++ b/gentoobrowse/emails/welcome.xml
@@ -0,0 +1,16 @@
+<?xml version="1.0"?>
+<view root="signup" style="emails/signup.xslt" xmlns:xi="http://www.w3.org/2001/XInclude"
+ xmlns:project2="http://project2.randomdan.homeip.net">
+ <xi:include href="../datasources/postgres.xml" />
+ <project2:sqlview name="verifyguids" recordname="verifyguid" datasource="postgres">
+ <sql>
+ SELECT userid, CAST(verifyguid AS TEXT) AS guid
+ FROM users u
+ WHERE useremail = ?
+ AND verifyguid IS NOT NULL
+ </sql>
+ <parameters>
+ <param bind="0" value="$email" />
+ </parameters>
+ </project2:sqlview>
+</view>
diff --git a/gentoobrowse/present/confirm.xml b/gentoobrowse/present/confirm.xml
new file mode 100644
index 0000000..5784bdf
--- /dev/null
+++ b/gentoobrowse/present/confirm.xml
@@ -0,0 +1,13 @@
+<?xml version="1.0"?>
+<view name="confirm" root="gentoo" style="login.xslt" xmlns:xi="http://www.w3.org/2001/XInclude"
+ xmlns:project2="http://project2.randomdan.homeip.net">
+ <project2:rawview>
+ <para>Please enter the confirmation code from your welcome email.</para>
+ <form caption="Confirmation" submit="Confirm" action="/doconfirm" method="post">
+ <input type="text" name="verifyguid" caption="Confirmation code"
+ xslvalue="/gentoo/project2:params/project2:param[@name='verifyguid']" />
+ </form>
+ </project2:rawview>
+</view>
+
+
diff --git a/gentoobrowse/request/doconfirm.xml b/gentoobrowse/request/doconfirm.xml
new file mode 100644
index 0000000..70a1128
--- /dev/null
+++ b/gentoobrowse/request/doconfirm.xml
@@ -0,0 +1,35 @@
+<?xml version="1.0"?>
+<view name="doconfirm" present="accountHome" xmlns:xi="http://www.w3.org/2001/XInclude"
+ xmlns:project2="http://project2.randomdan.homeip.net">
+ <xi:include href="../datasources/postgres.xml" />
+ <project2:sqlcheck datasource="postgres" testOp="=" testValue="1" present="login" name="checkUserAuth">
+ <message>Invalid username or password</message>
+ <sql>
+ SELECT COUNT(*)
+ FROM users
+ WHERE verifyguid = ?
+ </sql>
+ <parameters>
+ <param bind="0" value="$verifyguid" />
+ </parameters>
+ </project2:sqlcheck>
+ <project2:sqliterate datasource="postgres" name="getUidFromDatabase">
+ <sql>
+ SELECT userid
+ FROM users
+ WHERE verifyguid = ?
+ </sql>
+ <parameters>
+ <param bind="0" value="$verifyguid" />
+ </parameters>
+ <tasks>
+ <project2:sessionset key="loggedInUserID" value="^userid" name="setUidInSession" />
+ </tasks>
+ </project2:sqliterate>
+ <project2:sqltask datasource="postgres">
+ <sql>UPDATE users SET verifyguid = NULL WHERE verifyguid = ?</sql>
+ <parameters>
+ <param bind="0" value="$verifyguid" />
+ </parameters>
+ </project2:sqltask>
+</view>
diff --git a/gentoobrowse/request/dologin.xml b/gentoobrowse/request/dologin.xml
index 0eda6bc..dde399f 100644
--- a/gentoobrowse/request/dologin.xml
+++ b/gentoobrowse/request/dologin.xml
@@ -23,6 +23,18 @@
<param bind="1" value="$password" />
</parameters>
</project2:sqlcheck>
+ <project2:sqlcheck datasource="postgres" testOp="=" testValue="1" present="confirm" name="checkConfirmed">
+ <message>Confirmation code required</message>
+ <sql>
+ SELECT COUNT(*)
+ FROM users
+ WHERE username = ?
+ AND verifyguid IS NULL
+ </sql>
+ <parameters>
+ <param bind="0" value="$username" />
+ </parameters>
+ </project2:sqlcheck>
<project2:sqliterate datasource="postgres" name="getUidFromDatabase">
<sql>
SELECT userid
diff --git a/gentoobrowse/request/dosignup.xml b/gentoobrowse/request/dosignup.xml
new file mode 100644
index 0000000..158853d
--- /dev/null
+++ b/gentoobrowse/request/dosignup.xml
@@ -0,0 +1,48 @@
+<?xml version="1.0"?>
+<view name="dosignup" present="confirm" xmlns:xi="http://www.w3.org/2001/XInclude"
+ xmlns:project2="http://project2.randomdan.homeip.net">
+ <xi:include href="../datasources/postgres.xml" />
+ <project2:regexcheck apply-to="$username" present="signup" name="usernameEntered">
+ <regex>.+</regex>
+ <message>User name required</message>
+ </project2:regexcheck>
+ <project2:regexcheck apply-to="$password" present="signup" name="passwordLength">
+ <regex>.{6,}</regex>
+ <message>Password too short</message>
+ </project2:regexcheck>
+ <project2:sqlcheck datasource="postgres" testOp="=" testValue="0" present="signup" name="freeUsername">
+ <message>Username already used</message>
+ <sql>
+ SELECT COUNT(*)
+ FROM users
+ WHERE username = ?
+ </sql>
+ <parameters>
+ <param bind="0" value="$username" />
+ </parameters>
+ </project2:sqlcheck>
+ <project2:sqlcheck datasource="postgres" testOp="=" testValue="0" present="signup" name="freeEmail">
+ <message>Email address already used</message>
+ <sql>
+ SELECT COUNT(*)
+ FROM users
+ WHERE useremail = ?
+ </sql>
+ <parameters>
+ <param bind="0" value="$email" />
+ </parameters>
+ </project2:sqlcheck>
+ <project2:sqltask datasource="postgres">
+ <sql>INSERT INTO users(username, userrealname, userpassword, useremail, verifyguid)
+ VALUES(?, ?, ?, ?, uuid_generate_v4())</sql>
+ <parameters>
+ <param bind="0" value="$username" />
+ <param bind="1" value="$realname" />
+ <param bind="2" value="$password" />
+ <param bind="3" value="$email" />
+ </parameters>
+ </project2:sqltask>
+ <project2:sendmail to="$email" server="smtp.random.lan:25" subject="Welcome to Gentoo Browse"
+ present="welcome" from="noreply@gentoobrowse.randomdan.homeip.net" />
+</view>
+