<?xml version="1.0" encoding="UTF-8"?>
<commit>
  <added type="array"/>
  <modified type="array">
    <modified>
      <diff>@@ -11,13 +11,14 @@ module JsChat
   class User
     include JsChat::FloodProtection
 
-    attr_accessor :name, :connection, :rooms, :last_activity
+    attr_accessor :name, :connection, :rooms, :last_activity, :identified
 
     def initialize(connection)
       @name = nil
       @connection = connection
       @rooms = []
       @last_activity = Time.now.utc
+      @identified = false
     end
 
     def to_json
@@ -28,6 +29,7 @@ module JsChat
       if @connection and @connection.name_taken? name
         raise JsChat::Errors::InvalidName.new(:name_taken, 'Name taken')
       elsif User.valid_name?(name)
+        @identified = true
         @name = name
       else
         raise JsChat::Errors::InvalidName.new(:invalid_name, 'Invalid name')
@@ -189,8 +191,10 @@ module JsChat
 
   # {&quot;identify&quot;:&quot;alex&quot;}
   def identify(name, options = {})
-    if name_taken? name
-      Error.new(:name_taken, 'Name already taken')
+    if @user and @user.identified
+      Error.new :already_identified, 'You have already identified'
+    elsif name_taken? name
+      Error.new :name_taken, 'Name already taken'
     else
       @user.name = name
       { 'display' =&gt; 'identified', 'identified' =&gt; @user }</diff>
      <filename>jschat.rb</filename>
    </modified>
    <modified>
      <diff>@@ -21,6 +21,7 @@ module JsChat
       101 =&gt; :invalid_name,
       104 =&gt; :not_online,
       105 =&gt; :identity_required,
+      106 =&gt; :already_identified,
       # 2xx: Room errors
       200 =&gt; :already_joined,
       201 =&gt; :invalid_room,</diff>
      <filename>lib/errors.rb</filename>
    </modified>
    <modified>
      <diff>@@ -58,6 +58,12 @@ class TestJsChat &lt; Test::Unit::TestCase
     assert_equal JsChat::Errors::Codes.invert[:invalid_name], response['error']['code']
   end
 
+  def test_identify_twice_fails
+    identify_as 'alex'
+    result = JSON.parse identify_as('alex')
+    assert_equal 106, result['error']['code']
+  end
+
   def test_ensure_nicks_are_unique
     identify_as 'alex'
 
@@ -96,12 +102,6 @@ class TestJsChat &lt; Test::Unit::TestCase
     assert_equal JsChat::Errors::Codes.invert[:already_joined], response['error']['code']
   end
 
-  def test_identify_twice
-    identify_as 'nick'
-    response = JSON.parse @jschat.receive_data({ 'identify' =&gt; 'nick' }.to_json)
-    assert_equal JsChat::Errors::Codes.invert[:name_taken], response['error']['code']
-  end
-
   def test_names
     identify_as 'nick', '#oublinet'
 </diff>
      <filename>test/server_test.rb</filename>
    </modified>
  </modified>
  <removed type="array"/>
  <parents type="array">
    <parent>
      <id>df91bf720736d334ff84bd8b27c06b86e9d99f5d</id>
    </parent>
  </parents>
  <author>
    <name>My Name</name>
    <email>alex@helicoid.net</email>
  </author>
  <url>http://github.com/alexyoung/jschat/commit/7d1b01152ab4813722ccfec4a3bfdf209360908c</url>
  <id>7d1b01152ab4813722ccfec4a3bfdf209360908c</id>
  <committed-date>2009-05-24T03:29:53-07:00</committed-date>
  <authored-date>2009-05-24T03:29:53-07:00</authored-date>
  <message>Users can no-longer identify twice.  Closes #50.</message>
  <tree>d93d8f13ce0153323a2a91a8886ee6231846752f</tree>
  <committer>
    <name>My Name</name>
    <email>alex@helicoid.net</email>
  </committer>
</commit>
