     res.header "Access-Control-Allow-Headers", "X-Requested-With"
     next()
 
+# DebugMode
+DebugMode = on
+app.__debug = ->
+  DebugMode = on
+
 # GET and POST requests
 api =
   "v0":
+
+
+    # ------------
+    # Registration
+    # ------------
+
+    "post_register": (req, res) ->
+      user =
+        name: req.body.name
+        email: req.body.email
+        password: req.body.password
+      Auth.register(user.name, user.email, user.password)
+        .then (token) ->
+          res.send token
+        .fail (err) ->
+          res.status(400).send err
+
+    "get_register/*": (req, res) ->
+      token = req.params[0]
+      User.getRegistration(token)
+        .then (user) ->
+          User.add(user.name, user.email, user.pass).then ->
+            res.send "success"
+        .fail (err) ->
+          res.send err
+
+
+    # -----
+    # Login
+    # -----
+
+    "post_login": (req, res) ->
+      user =
+        email: req.body.email
+        password: req.body.password
+      Auth.login(user.email, user.password)
+        .then (data) ->
+          res.send data
+        .fail (err) ->
+          res.status(401).send err
+
     "auth":
-      "post_register": (req, res) ->
-        user =
-          name: req.body.name
-          email: req.body.email
-          password: req.body.password
-        Auth.register(user.name, user.email, user.password)
-          .then (data) ->
-            res.send data
-          .fail (err) ->
-            res.status(400).send err
-
-      "post_login": (req, res) ->
-        user =
-          email: req.body.email
-          password: req.body.password
-        Auth.login(user.email, user.password)
-          .then (data) ->
-            res.send data
-          .fail (err) ->
-            res.status(401).send err
-
 
       # Password Resetting
       "get_forgot": (req, res) ->

        email = req.body.email
        Auth.generateResetToken(email)
          .then (token) ->
             message = "<h1>Hurrah! We have sent you an email containing a token</h1>"
             link = "<a href=\"http://localhost:5000/api/v0/auth/forgot/#{token}\">Reset Password</a>"

            if DebugMode then return res.send message + "<br><br>" + link


User    = require "./app/storage"
Q       = require "q"
Mail    = require "./app/mail"

port = process.env.PORT || 5000

