forked from shakacode/react_on_rails
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathpages_controller.rb
51 lines (40 loc) · 1.32 KB
/
pages_controller.rb
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
# frozen_string_literal: true
class PagesController < ApplicationController
include ReactOnRails::Controller
before_action do
session[:something_useful] = "REALLY USEFUL"
end
before_action :data
before_action :initialize_shared_store, only: %i[client_side_hello_world_shared_store_controller
server_side_hello_world_shared_store_controller]
# See files in spec/dummy/app/views/pages
private
def initialize_shared_store
redux_store("SharedReduxStore", props: @app_props_server_render)
end
def data
xss_payload = { "<script>window.alert('xss1');</script>" => '<script>window.alert("xss2");</script>' }
# This is the props used by the React component.
@app_props_server_render = {
helloWorldData: {
name: "Mr. Server Side Rendering"
}.merge(xss_payload),
modificationTarget: "server-only"
}
@app_props_hello = {
helloWorldData: {
name: "Mrs. Client Side Rendering"
}.merge(xss_payload)
}
@app_props_hello_from_turbo_stream = {
helloTurboStreamData: {
name: "Mrs. Client Side Rendering From Turbo Stream"
}.merge(xss_payload)
}
@app_props_hello_again = {
helloWorldData: {
name: "Mrs. Client Side Hello Again"
}.merge(xss_payload)
}
end
end