-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
8 changed files
with
60 additions
and
101 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,60 +1,11 @@ | ||
module Qweixin | ||
class UsersController < ApplicationController | ||
before_action :set_user, only: %i[ show edit update destroy ] | ||
skip_before_action :verify_authenticity_token | ||
before_action :require_auth_token!, only: %i[ show ] | ||
|
||
# GET /users | ||
def index | ||
@users = User.all | ||
end | ||
|
||
# GET /users/1 | ||
# GET /weixin/user | ||
def show | ||
render json: { errcode: 0, errmsg: "ok", user_info: @current_user.as_json(only: %i[ id nickname mobile avatar ]) } | ||
end | ||
|
||
# GET /users/new | ||
def new | ||
@user = User.new | ||
end | ||
|
||
# GET /users/1/edit | ||
def edit | ||
end | ||
|
||
# POST /users | ||
def create | ||
@user = User.new(user_params) | ||
|
||
if @user.save | ||
redirect_to @user, notice: "User was successfully created." | ||
else | ||
render :new, status: :unprocessable_entity | ||
end | ||
end | ||
|
||
# PATCH/PUT /users/1 | ||
def update | ||
if @user.update(user_params) | ||
redirect_to @user, notice: "User was successfully updated.", status: :see_other | ||
else | ||
render :edit, status: :unprocessable_entity | ||
end | ||
end | ||
|
||
# DELETE /users/1 | ||
def destroy | ||
@user.destroy! | ||
redirect_to users_url, notice: "User was successfully destroyed.", status: :see_other | ||
end | ||
|
||
private | ||
# Use callbacks to share common setup or constraints between actions. | ||
def set_user | ||
@user = User.find(params[:id]) | ||
end | ||
|
||
# Only allow a list of trusted parameters through. | ||
def user_params | ||
params.require(:user).permit(:session_key, :unionid, :openid, :last_appid) | ||
end | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,6 @@ | ||
Qweixin::Engine.routes.draw do | ||
resources :users | ||
resource :user | ||
|
||
get "app_login", to: "sessions#code2session" | ||
get "app_checksession", to: "sessions#checksession" | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters