From 9d72bb1ffa7c3287bc1ce6aa4043e489f3ff416b Mon Sep 17 00:00:00 2001 From: Martin Edenhofer Date: Sun, 20 Jan 2013 02:27:47 +0100 Subject: [PATCH] Added duplicate email check. --- app/controllers/users_controller.rb | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/app/controllers/users_controller.rb b/app/controllers/users_controller.rb index a9e527d2d..2e5189eda 100644 --- a/app/controllers/users_controller.rb +++ b/app/controllers/users_controller.rb @@ -161,6 +161,15 @@ curl http://localhost/api/users.json -v -u #{login}:#{password} -H "Content-Type end end + # check if user already exists + if user.email + exists = User.where( :email => user.email ).first + if exists + render :json => { :error => 'User already exists!' }, :status => :unprocessable_entity + return + end + end + user.save # send inviteation if needed / only if session exists