mirror of
https://github.com/penpot/penpot.git
synced 2025-05-18 17:46:10 +02:00
Import backend code inside the repository.
This commit is contained in:
parent
e21798f1ed
commit
de57630c14
113 changed files with 8040 additions and 0 deletions
33
backend/src/uxbox/frontend/auth.clj
Normal file
33
backend/src/uxbox/frontend/auth.clj
Normal file
|
@ -0,0 +1,33 @@
|
|||
;; This Source Code Form is subject to the terms of the Mozilla Public
|
||||
;; License, v. 2.0. If a copy of the MPL was not distributed with this
|
||||
;; file, You can obtain one at http://mozilla.org/MPL/2.0/.
|
||||
;;
|
||||
;; Copyright (c) 2016 Andrey Antukh <niwi@niwi.nz>
|
||||
|
||||
(ns uxbox.frontend.auth
|
||||
(:require [clojure.spec :as s]
|
||||
[catacumba.core :as ct]
|
||||
[catacumba.http :as http]
|
||||
[promesa.core :as p]
|
||||
[uxbox.util.spec :as us]
|
||||
[uxbox.services :as sv]
|
||||
[uxbox.util.uuid :as uuid]
|
||||
[uxbox.util.response :refer (rsp)]))
|
||||
|
||||
(s/def ::scope string?)
|
||||
(s/def ::login (s/keys :req-un [::us/username ::us/password ::scope]))
|
||||
|
||||
(defn login
|
||||
[{data :data}]
|
||||
(let [data (us/conform ::login data)
|
||||
message (assoc data :type :login)]
|
||||
(->> (sv/novelty message)
|
||||
(p/map #(http/ok (rsp %))))))
|
||||
|
||||
;; TODO: improve authorization
|
||||
|
||||
(defn authorization
|
||||
[{:keys [identity] :as context}]
|
||||
(if identity
|
||||
(ct/delegate {:identity (uuid/from-string (:id identity))})
|
||||
(http/forbidden (rsp nil))))
|
Loading…
Add table
Add a link
Reference in a new issue