   (let [email (get-in request [:session :user-login])]
     (user/delete-user! email)
     (redirect-to-profile-deleted)))
-
-(defn generate-login-access-token [user]
-  (:token (cl-token/create-token nil user)))
-
-(defn redirect-to-profile-from-sign-in [user]
-  (assoc (r/redirect (routes/path :show-profile)) :session {:user-login (:login user)
-                                                            :access_token (generate-login-access-token user)}))
 
 (defn redirect-to-profile-created [user request]
   (-> (r/redirect (routes/path :show-profile-created))

        request-with-validation-errors (assoc-in request [:context :errors] err)]
    (if (empty? err)
      (if-let [user (user/authenticate-and-retrieve-user email password)]
        (cond return-to (redirect-to-authorisation return-to user)
              :default (redirect-to-profile-from-sign-in user))
        (-> request-with-validation-errors
            (assoc-in [:context :errors :credentials] :invalid)
            show-sign-in-form))

    (-> (r/redirect (routes/path :home)) (preserve-session request))
    (sh/enlive-response (sign-in/sign-in-form request) (:context request))))

(defn generate-login-access-token [user]
  (:token (cl-token/create-token nil user)))

(defn sign-in [request]
  (let [return-to (get-in request [:session :return-to])
        params (:params request)
