注册用户时好多用户字段没有,默认为null
This commit is contained in:
parent
efa08adf4e
commit
6cb3f9e53c
|
@ -12,7 +12,7 @@ module Mobile
|
|||
end
|
||||
|
||||
def authenticate!
|
||||
raise 'Unauthorized. Invalid or expired token.' unless current_user
|
||||
raise('Unauthorized. Invalid or expired token.') unless current_user
|
||||
end
|
||||
|
||||
def current_user
|
||||
|
|
|
@ -14,7 +14,9 @@ module Mobile
|
|||
us = UsersService.new
|
||||
user = us.register params.merge(:password_confirmation => params[:password],
|
||||
:should_confirmation_password => true)
|
||||
binding.pry
|
||||
raise "register failed #{user.errors.full_messages}" if user.new_record?
|
||||
|
||||
present :data, user, with: Mobile::Entities::User
|
||||
present :status, 0
|
||||
end
|
||||
|
|
|
@ -1,22 +1,28 @@
|
|||
module Mobile
|
||||
module Entities
|
||||
class User < Grape::Entity
|
||||
expose :id
|
||||
def self.user_expose(f)
|
||||
expose f do |u,opt|
|
||||
u.send(f) if u.respond_to?(f)
|
||||
end
|
||||
end
|
||||
|
||||
expose :id
|
||||
#头像
|
||||
expose :img_url
|
||||
user_expose :img_url
|
||||
#昵称
|
||||
expose :nickname
|
||||
#性别
|
||||
expose :gender
|
||||
user_expose :gender
|
||||
#我的二维码
|
||||
#工作单位
|
||||
expose :work_unit
|
||||
user_expose :work_unit
|
||||
#邮箱地址
|
||||
expose :mail
|
||||
user_expose :mail
|
||||
#地区
|
||||
expose :location
|
||||
user_expose :location
|
||||
#签名
|
||||
expose :brief_introduction
|
||||
user_expose :brief_introduction
|
||||
end
|
||||
end
|
||||
|
||||
|
|
|
@ -7,6 +7,7 @@ module Mobile
|
|||
@app.call(@env)
|
||||
rescue =>e
|
||||
message = {status: 1, message: e.message }.to_json
|
||||
puts(detail: e.backtrace.join("\n")) if Rails.env.development?
|
||||
status = 200
|
||||
headers = { 'Content-Type' => content_type }
|
||||
Rack::Response.new([message], status, headers).finish
|
||||
|
@ -15,4 +16,4 @@ module Mobile
|
|||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
Loading…
Reference in New Issue