Skip to content

Commit

Permalink
add register page and api login
Browse files Browse the repository at this point in the history
  • Loading branch information
damianham committed Apr 4, 2020
1 parent 4faa333 commit 56f4916
Show file tree
Hide file tree
Showing 9 changed files with 567 additions and 122 deletions.
2 changes: 1 addition & 1 deletion app/.amber.yml.lqd
Original file line number Diff line number Diff line change
Expand Up @@ -38,4 +38,4 @@ watch:
build_commands:
- echo watching assets
run_commands:
- yarn watch
- npm run watch
15 changes: 9 additions & 6 deletions app/config/routes.cr
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
Amber::Server.configure do |app|
pipeline :web, :auth do
pipeline :web do
# Plug is the method to use connect a pipe (middleware)
# A plug accepts an instance of HTTP::Handler
# plug Amber::Pipe::PoweredByAmber.new
Expand All @@ -23,6 +23,8 @@ Amber::Server.configure do |app|
plug Amber::Pipe::Logger.new
plug Amber::Pipe::Session.new
plug Amber::Pipe::CORS.new
# enable this pipe for JWT support
# plug AuthenticateJWT.new
end

# All static content will run these transformations
Expand All @@ -33,15 +35,16 @@ Amber::Server.configure do |app|
end

routes :web do
get "/authenticateWithToken", HomeController, :authenticate_jwt
get "/me", HomeController, :me
websocket "/model", ModelSocket
websocket "/signal", SignalSocket
get "/", HomeController, :index
post "/", HomeController, :token_sign_in_helper
end

routes :api do
get "/authenticateWithToken", HomeController, :authenticate_jwt
post "/api/auth/signin", HomeController, :signin
get "/me", HomeController, :me
post "/", HomeController, :token_sign_in_helper
websocket "/model", ModelSocket
websocket "/signal", SignalSocket
end

routes :static do
Expand Down
61 changes: 53 additions & 8 deletions app/src/assets/javascripts/app.js.lqd
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,12 @@ import HeaderLinks from 'components/Header/HeaderLinks.jsx'
import Auth from '../../lib/js/auth'
import routes from '../../modules/js/routes'

import Components from 'views/Components/Components.jsx'
import LandingPage from 'views/LandingPage/LandingPage.jsx'
import ProfilePage from 'views/ProfilePage/ProfilePage.jsx'
import LoginPage from 'views/LoginPage/LoginPage.jsx'
import RegisterPage from 'views/RegisterPage/RegisterPage.jsx'

const dashboardRoutes = []

// define a mapping from a text name used as the icon ID in routes in
Expand Down Expand Up @@ -116,6 +122,43 @@ const styles = (theme) => ({
}
})

const static_routes = [ {
path: '/components',
exact: true,
type: 'index',
name: 'Components',
main: Components,
icon: 'View'
}, {
path: '/landing-page',
exact: true,
type: 'index',
name: 'Landing Example',
main: LandingPage,
icon: 'Info'
}, {
path: '/profile-page',
exact: true,
type: 'index',
name: 'Profile Example',
main: ProfilePage,
icon: 'Face'
}, {
path: '/login-page',
exact: true,
type: 'index',
name: 'Login',
main: LoginPage,
icon: 'Login'
}, {
path: '/signup',
exact: true,
type: 'index',
name: 'Signup',
main: RegisterPage,
icon: 'Signup'
}]

class ListItemLink extends React.Component {
constructor (props, state) {
super(props, state)
Expand Down Expand Up @@ -335,14 +378,7 @@ class App extends React.Component {
{ this.isAuthenticated() ? (
<ListItemLink exact key='/profile-page' to='/profile-page' primary='Profile' icon={<PersonIcon />} />
) : (
<li>
<a href='/signup'>
<ListItem button >
<ListItemIcon>{<PersonAddIcon />}</ListItemIcon>
<ListItemText primary="Sign Up" />
</ListItem>
</a>
</li>
<ListItemLink exact key='/register-page' to='/signup' primary='Register' icon={<PersonAddIcon />} />
)
}
</List>
Expand All @@ -357,6 +393,15 @@ class App extends React.Component {
component={route.main}
/>
))}
{static_routes.map((route, index) => (
<Route
key={index}
path={route.path}
exact={route.exact}
component={route.main}
/>
))
}
</Switch>
</div>
)
Expand Down
Loading

0 comments on commit 56f4916

Please sign in to comment.