Permalink
Browse files

Merge branch 'promote'

Conflicts:
	project.clj
	src/clojars/db.clj
	src/clojars/friend/registration.clj
	src/clojars/web/user.clj
  • Loading branch information...
2 parents c70d311 + e7bf69d commit 1dc2cc23dde43b6b19873f24593609edd06da028 @technomancy technomancy committed Nov 13, 2012
View
@@ -42,7 +42,7 @@ it. Regardless of how you run it, you first need to do some setup:
* Debian: `apt-get install sqlite3`
* Mac OS X Homebrew: `brew install sqlite`
-3. Run the DB migrations: `lein run -m clojars.db.migrate`
+3. Run the DB migrations: `lein migrate`
To run the application using Leinigen 2:
@@ -0,0 +1,75 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
+ <modelVersion>4.0.0</modelVersion>
+ <groupId>robert</groupId>
+ <artifactId>hooke</artifactId>
+ <packaging>jar</packaging>
+ <version>1.2.0</version>
+ <name>hooke</name>
+ <licenses>
+ <license>
+ <name>Eclipse Public License</name>
+ <url>http://www.eclipse.org/legal/epl-v10.html</url>
+ </license>
+ </licenses>
+ <scm>
+ <connection>scm:git:git://github.com/technomancy/robert-hooke.git</connection>
+ <developerConnection>scm:git:ssh://git@github.com/technomancy/robert-hooke.git</developerConnection>
+ <tag>e0d11489a2421592a545847d352f168a939eafeb</tag>
+ <url>https://github.com/technomancy/robert-hooke</url>
+ </scm>
+ <build>
+ <sourceDirectory>src</sourceDirectory>
+ <testSourceDirectory>test</testSourceDirectory>
+ <resources>
+ <resource>
+ <directory>resources</directory>
+ </resource>
+ </resources>
+ <testResources>
+ <testResource>
+ <directory>dev-resources</directory>
+ </testResource>
+ <testResource>
+ <directory>resources</directory>
+ </testResource>
+ </testResources>
+ <directory>target</directory>
+ <outputDirectory>target/classes</outputDirectory>
+ </build>
+ <repositories>
+ <repository>
+ <id>central</id>
+ <url>http://repo1.maven.org/maven2/</url>
+ <snapshots>
+ <enabled>true</enabled>
+ </snapshots>
+ <releases>
+ <enabled>true</enabled>
+ </releases>
+ </repository>
+ <repository>
+ <id>clojars</id>
+ <url>https://clojars.org/repo/</url>
+ <snapshots>
+ <enabled>true</enabled>
+ </snapshots>
+ <releases>
+ <enabled>true</enabled>
+ </releases>
+ </repository>
+ </repositories>
+ <dependencies>
+ <dependency>
+ <groupId>org.clojure</groupId>
+ <artifactId>clojure</artifactId>
+ <version>1.4.0</version>
+ <scope>test</scope>
+ </dependency>
+ </dependencies>
+</project>
+
+<!-- This file was autogenerated by Leiningen.
+ Please do not edit it directly; instead edit project.clj and regenerate it.
+ It should not be considered canonical data. For more information see
+ https://github.com/technomancy/leiningen -->
@@ -0,0 +1,11 @@
+-----BEGIN PGP SIGNATURE-----
+Version: GnuPG v1.4.10 (GNU/Linux)
+
+iQEbBAABAgAGBQJQdJMAAAoJEE0jHTttgAF4mv0H+I0Cut5EbKnvCZctY9KvJJqN
+07Q4f8gwq7kPx/DGtIyd9rXTSchg0j5R/rg19MSM8yXF+LoYbrmTsqkjkiSu4Sv8
+M3bbeIfxD0rBtu2jmb6zqQcbPX3/j+urdqZKRdqeLvK3sr1fjbqUfTzyG1+hvsJR
+uP3R8a74UKDiRLhaBn/HtH0Kl8t236TGWBbVdXO57YggdXw1CJm32jjU14PUB6mp
+Vee90bFhiNv03i07c+NETmOQiiR+AohP7Iom4lYzs6IaotdejXyuyNbKlIbpDSqu
+YS9Ez0OvB60zSseht2V0eqa+/PANDIUskUr1SRVKF6sfWSCGZsWCNAbGdJb53w==
+=+70a
+-----END PGP SIGNATURE-----
@@ -1,15 +1,23 @@
<?xml version="1.0" encoding="UTF-8"?>
-<project>
+<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>robert</groupId>
<artifactId>hooke</artifactId>
- <version>1.1.2</version>
+ <packaging>jar</packaging>
+ <version>1.2.0</version>
<name>hooke</name>
<description>Hooke your functions!</description>
+ <url>https://github.com/technomancy/robert-hooke</url>
+ <licenses>
+ <license>
+ <name>Eclipse Public License</name>
+ <url>http://www.eclipse.org/legal/epl-v10.html</url>
+ </license>
+ </licenses>
<scm>
<connection>scm:git:git://github.com/technomancy/robert-hooke.git</connection>
<developerConnection>scm:git:ssh://git@github.com/technomancy/robert-hooke.git</developerConnection>
- <tag>19ce36f7a3b0704cdcde821ebf4b4721ec903efb</tag>
+ <tag>e0d11489a2421592a545847d352f168a939eafeb</tag>
<url>https://github.com/technomancy/robert-hooke</url>
</scm>
<build>
@@ -22,34 +30,48 @@
</resources>
<testResources>
<testResource>
- <directory>test-resources</directory>
+ <directory>dev-resources</directory>
+ </testResource>
+ <testResource>
+ <directory>resources</directory>
</testResource>
</testResources>
+ <directory>target</directory>
+ <outputDirectory>target/classes</outputDirectory>
</build>
<repositories>
<repository>
<id>central</id>
- <url>http://repo1.maven.org/maven2</url>
- </repository>
- <repository>
- <id>clojure</id>
- <url>http://build.clojure.org/releases</url>
- </repository>
- <repository>
- <id>clojure-snapshots</id>
- <url>http://build.clojure.org/snapshots</url>
+ <url>http://repo1.maven.org/maven2/</url>
+ <snapshots>
+ <enabled>true</enabled>
+ </snapshots>
+ <releases>
+ <enabled>true</enabled>
+ </releases>
</repository>
<repository>
<id>clojars</id>
- <url>http://clojars.org/repo/</url>
+ <url>https://clojars.org/repo/</url>
+ <snapshots>
+ <enabled>true</enabled>
+ </snapshots>
+ <releases>
+ <enabled>true</enabled>
+ </releases>
</repository>
</repositories>
<dependencies>
<dependency>
<groupId>org.clojure</groupId>
<artifactId>clojure</artifactId>
- <version>1.3.0-beta1</version>
+ <version>1.4.0</version>
<scope>test</scope>
</dependency>
</dependencies>
</project>
+
+<!-- This file was autogenerated by Leiningen.
+ Please do not edit it directly; instead edit project.clj and regenerate it.
+ It should not be considered canonical data. For more information see
+ https://github.com/technomancy/leiningen -->
@@ -0,0 +1,11 @@
+-----BEGIN PGP SIGNATURE-----
+Version: GnuPG v1.4.10 (GNU/Linux)
+
+iQEcBAABAgAGBQJQdJL4AAoJEE0jHTttgAF4neIH/3P2E6PcNXMJUZWVrIC+YK1b
+FdnuUqL+a8mLYOT1gJkYdnIMM+GhgfWTi6MNTOtaO7ctE1i6rPk2ulW3wCybjN4G
+UwosW1uGthnOjlMcfaOB5hzq71emwgMslmyUn3OhN5qddw4StPuBL166Hj0ebd5M
+QdKFmWLekRJDXzKZ9+cv/MJ19MI3NTrQ1q8dCmfwOJp28WnwQvhg/RMiTRr/q5wE
+RYov2zs57bbEPVH9MvYPJW3EjgxAMdxpDg+7pyrFALdiZum/o8O6BluMTrOz8gEj
+ruD3Z2avIhRVMJGISA2vK9ffdv6NSjgUNRktbi2+n4t31oJJ8xWlDg07zLUscbQ=
+=zHFU
+-----END PGP SIGNATURE-----
View
@@ -32,9 +32,8 @@
:plugins [[lein-ring "0.7.3" :exclusions [thneed]]
;fix downloading -snapshot all the time
[thneed "1.0.0"]]
+ :aliases {"migrate" ["run" "-m" "clojars.db.migrate"]}
:ring {:handler clojars.web/clojars-app}
:aot [clojars.scp]
:main clojars.main
:min-lein-version "2.0.0")
-
-
View
@@ -16,8 +16,9 @@
{:username user :password password})))
(defn authorized? [account group]
- (let [names# (group-membernames group)]
- (or (some #{account} names#) (empty? names#))))
+ (if account
+ (let [names (group-membernames group)]
+ (or (some #{account} names) (empty? names)))))
(defmacro require-authorization [group & body]
`(if (authorized? ~'account ~group)
View
@@ -3,9 +3,9 @@
[clojure.java.io :as io]
[clojars.config :refer [config]]
[korma.db :refer [defdb transaction rollback]]
- [korma.core :refer [defentity select group fields order
- modifier exec-raw where limit values
- raw insert update set-fields offset]])
+ [korma.core :refer [defentity select group fields order join
+ modifier exec-raw where limit values with
+ has-many raw insert update set-fields offset]])
(:import java.security.MessageDigest
java.util.Date
java.io.File
@@ -74,6 +74,11 @@
(defn group-membernames [groupname]
(map :user (select groups (fields :user) (where {:name groupname}))))
+(defn group-keys [groupname]
+ (map :pgp_key (select users (fields :pgp_key)
+ (join groups (= :users.user :groups.user))
+ (where {:groups.name groupname}))))
+
(defn jars-by-username [username]
(select jars
(where {:user username})
@@ -176,12 +181,13 @@
(* (- current-page 1) per-page)
per-page))))
-(defn add-user [email username password ssh-key]
+(defn add-user [email username password ssh-key pgp-key]
(insert users
(values {:email email
:user username
:password (bcrypt password)
:ssh_key ssh-key
+ :pgp_key pgp-key
:created (get-time)
;;TODO: remove salt field
:salt ""}))
@@ -190,11 +196,12 @@
:user username}))
(write-key-file (:key-file config)))
-(defn update-user [account email username password ssh-key]
+(defn update-user [account email username password ssh-key pgp-key]
(let [fields {:email email
:user username
:salt ""
- :ssh_key ssh-key}]
+ :ssh_key ssh-key
+ :pgp_key pgp-key}]
(update users
(set-fields (if (empty? password)
fields
@@ -19,6 +19,9 @@
(sql/do-commands (str "CREATE INDEX IF NOT EXISTS jars_idx0 "
"ON jars (group_name, jar_name, created DESC)")))
+(defn add-pgp-key []
+ (sql/do-commands "ALTER TABLE users ADD COLUMN pgp_key TEXT"))
+
;; migrations mechanics
(defn run-and-record [migration]
@@ -50,4 +53,5 @@
(defn -main []
(migrate #'initial-schema
#'add-promoted-field
- #'add-jars-index))
+ #'add-jars-index
+ #'add-pgp-key))
@@ -6,14 +6,15 @@
[clojars.db :refer [add-user]]
[valip.core :refer [validate]]))
-(defn register [{:keys [email username password confirm ssh-key]}]
+(defn register [{:keys [email username password confirm ssh-key pgp-key]}]
(if-let [errors (apply validate {:email email
:username username
:password password
- :ssh-key ssh-key}
+ :ssh-key ssh-key
+ :pgp-key pgp-key}
(new-user-validations confirm))]
(response (register-form (apply concat (vals errors)) email username ssh-key))
- (do (add-user email username password ssh-key)
+ (do (add-user email username password ssh-key pgp-key)
(workflow/make-auth {:identity username :username username}))))
(defn workflow [{:keys [uri request-method params]}]
Oops, something went wrong.

0 comments on commit 1dc2cc2

Please sign in to comment.