Skip to content

Bug Shooting Challenge の事前問題

Notifications You must be signed in to change notification settings

mixi-challenge/bug-shooting-challenge-pre

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

4 Commits
 
 

Repository files navigation

Bug Shooting Challenge 事前問題

回答方法

エントリーシート内にある回答フォームにGistのURLを貼ってください。

回答例

こちらのGistを参考に、回答用のSecret Gistを作成してください。

問題1

ユーザ作成エンドポイント http://example.com/api/v1/users/new に対して下記のJSONデータをPOSTするcurlコマンドを記述してください。

{
  "name": "john.doe",
  "raw_password": "w33k_pa55w0rd"
}

問題2

下記はRailsで書かれたウェブアプリケーションのユーザ情報を返すAPIです。このままではパスワードのハッシュがAPIのレスポンスとして返ってしまいます。コントローラのshowアクションを修正し、crypted_passwordを除いたカラムを返すようにしてください。

usersテーブルスキーマ

カラム名 説明
id BIGINT ユーザに対して一意の識別番号。データベースの自動採番(AUTO INCREMENT)を使用。
name VARCHAR(16) ユーザ名
crypted_password CHAR(64) SHA256でハッシュ化したパスワード
created_at DATETIME ユーザの登録日時
updated_at DATETIME ユーザの最終更新日時
# users.sql
CREATE TABLE IF NOT EXISTS `users` (
  `id` BIGINT NOT NULL AUTO_INCREMENT,
  `name` VARCHAR(16) NOT NULL,
  `crypted_password` CHAR(64) NOT NULL,
  `created_at` DATETIME NOT NULL,
  `updated_at` DATETIME NOT NULL,
  PRIMARY KEY (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8;

Usersコントローラ

class UsersController < ActionController
  def show
    user = User.find(params[:id].to_i)
    render json: user
  end
end