         callback null, false
 
 
-  sendEmail: ({subject, firstName, username, action}, callback)->
+  sendEmail: ({ subject, firstName, username, action }, callback) ->
 
-    Tracker.track username, {to:@email, subject}, {firstName, @pin, action}
+    Tracker.track username, { to:@email, subject }, { firstName, @pin, action }
     callback null
 
 
-  @invalidatePin = (options, callback)->
-    {email, action, username} = options
+  @invalidatePin = (options, callback) ->
+    { email, action, username } = options
 
     email = emailsanitize email
 
-    @one {email, action, username}, (err, verify)->
+    @one { email, action, username }, (err, verify) ->
       return callback err  if err
-      return callback new KodingError "token not found" unless verify
+      return callback new KodingError 'token not found' unless verify
       verify.remove()
       callback null
 
 
-  @createNewPin = (options, callback)->
-    {username, action, email} = options
+  @createNewPin = (options, callback) ->
+    { username, action, email } = options
     pin = hat 16
 
     email = emailsanitize email
 
-    confirmation = new JVerificationToken {username, action, email, pin}
-    confirmation.save (err)-> callback err, confirmation
+    confirmation = new JVerificationToken { username, action, email, pin }
+    confirmation.save (err) -> callback err, confirmation
+
+

{Module} = require 'jraphical'
KodingError = require '../error'

emailsanitize = require './user/emailsanitize'

class PINExistsError extends Error
  constructor:(message)->
    return new PINExistsError(message) unless @ instanceof PINExistsError
    Error.call @
    @message = message
    @name = 'PINExistsError'

module.exports = class JVerificationToken extends Module

  {secure} = require 'bongo'
  crypto   = require 'crypto'
  hat      = require 'hat'
  Tracker  = require './tracker'

  @share()


          ['update-email', 'verify-account', 'test-verify']
        ]

  isAlive = (confirmation) ->
    # 20 Min. default TTL for tokens
    Math.round((Date.now() - confirmation.createdAt) / 60000) < 20

  @requestNewPin = (options, callback) ->

    { action, email, subject, user, firstName, resendIfExists } = options

    email = emailsanitize email  if email

