         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))
+        (let [access-token (generate-login-access-token user)]
+          (-> request
+              (cl-ep/return-to-handler (routes/path :show-profile))
+              (assoc-in [:session :user-login] (:login user))
+              (assoc-in [:session :access_token] access-token)))
         (-> 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 sign-in [request]
  (let [return-to (get-in request [:session :return-to])
        params (:params request)

  (let [email (get-in request [:session :user-login])]
    (user/delete-user! email)
    (redirect-to-profile-deleted)))

(defn redirect-to-profile-created [user request]
  (-> (r/redirect (routes/path :show-profile-created))
