From 40d0c03751de0e8a61a89f7c0e908002e9b63df7 Mon Sep 17 00:00:00 2001 From: guange <8863824@gmail.com> Date: Wed, 10 Dec 2014 16:51:19 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E6=94=B9=E7=94=A8=E6=88=B7=E5=AF=86?= =?UTF-8?q?=E7=A0=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/api/mobile/apis/users.rb | 22 +++++++++++++++++++++- 1 file changed, 21 insertions(+), 1 deletion(-) diff --git a/app/api/mobile/apis/users.rb b/app/api/mobile/apis/users.rb index d05809726..e80808c5d 100644 --- a/app/api/mobile/apis/users.rb +++ b/app/api/mobile/apis/users.rb @@ -38,7 +38,27 @@ module Mobile us = UsersService.new begin ue = us.edit_user params.merge(id: current_user.id) - {status: 0, data: ue} + present :data, user, with: Mobile::Entities::User + present :status, 0 + rescue => e + {status: 1, message: e.message} + end + end + + + desc '修改密码' + params do + requires :token, type: String + requires :password, type:String , desc: '原密码' + requires :new_password, type: String, desc: '新密码' + end + post 'password' do + authenticate! + us = UsersService.new + begin + ue = us.change_password params.merge(new_password_confirmation: params[:new_password]) + present :data, user, with: Mobile::Entities::User + present :status, 0 rescue => e {status: 1, message: e.message} end