All Projects → mxstbr → Login Flow

mxstbr / Login Flow

Licence: mit
🔑 A login/register flow built with React&Redux

Programming Languages

javascript
184084 projects - #8 most used programming language
CSS
56736 projects
ApacheConf
554 projects
HTML
75241 projects

Projects that are alternatives of or similar to Login Flow

Godom
Make DOM manipulation in Go as similar to JavaScript as possible. (via GopherJS or WebAssembly)
Stars: ✭ 125 (-92.27%)
Mutual labels:  frontend
Permit
An unopinionated authentication library for building Node.js APIs.
Stars: ✭ 1,654 (+2.22%)
Mutual labels:  authentication
Auth0 Javascript Samples
Auth0 Integration Samples for Vanilla JavaScript Applications
Stars: ✭ 130 (-91.97%)
Mutual labels:  authentication
Aowow
Database viewer for TrinityCore based on aowow by @LordJZ, based on the JS-Engine of Wowhead
Stars: ✭ 126 (-92.21%)
Mutual labels:  frontend
Githubtrending
Github前端趋势榜,每日更新前端热门项目。Tracking the most popular Github repos of frontend, updated daily
Stars: ✭ 127 (-92.15%)
Mutual labels:  frontend
Frontend Mindmaps
Frontend / React Developer Mindmaps for 2020. Roadmaps.
Stars: ✭ 129 (-92.03%)
Mutual labels:  frontend
Fast
Develop, build, deploy, redeploy, and teardown frontend projects fast.
Stars: ✭ 126 (-92.21%)
Mutual labels:  frontend
Chat Ui Kit React
Build your own chat UI with React components in few minutes. Chat UI Kit from chatscope is an open source UI toolkit for developing web chat applications.
Stars: ✭ 131 (-91.9%)
Mutual labels:  frontend
Javascript Code Challenges
A collection of JavaScript modern interview code challenges for beginners to experts
Stars: ✭ 2,710 (+67.49%)
Mutual labels:  frontend
Awesome Interview
Collection of awesome interview references.
Stars: ✭ 1,683 (+4.02%)
Mutual labels:  frontend
Ruby Auth0
Ruby toolkit for Auth0 API
Stars: ✭ 127 (-92.15%)
Mutual labels:  authentication
Laravel Auth
A powerful authentication, authorization and verification package built on top of Laravel. It provides developers with Role Based Access Control, Two-Factor Authentication, Social Authentication, and much more, compatible Laravel’s standard API and fully featured out of the box.
Stars: ✭ 128 (-92.09%)
Mutual labels:  authentication
Lock Screen
Simple and beautiful Lock Screen library to set an check pin code. Integrated with fingerprint authentication.
Stars: ✭ 130 (-91.97%)
Mutual labels:  authentication
Frontend
18F's Front End Guild –  content has been moved to https://github.com/18F/development-guide
Stars: ✭ 126 (-92.21%)
Mutual labels:  frontend
Django Auth Adfs
A Django authentication backend for Microsoft ADFS and AzureAD
Stars: ✭ 127 (-92.15%)
Mutual labels:  authentication
Eshoponcontainersddd
Fork of dotnet-architecture/eShopOnContainers in full DDD/CQRS design using my own patterns
Stars: ✭ 126 (-92.21%)
Mutual labels:  frontend
Webpack Starter
✨ A lightweight foundation for your next webpack based frontend project.
Stars: ✭ 1,745 (+7.85%)
Mutual labels:  frontend
Next Advanced Apollo Starter
Advanced, but minimalistic Next.js pre-configured starter with focus on DX
Stars: ✭ 131 (-91.9%)
Mutual labels:  authentication
Mod auth cas
An Apache httpd module for integrating with Apereo CAS Server project.
Stars: ✭ 130 (-91.97%)
Mutual labels:  authentication
Percy
Build frontend browser apps with Rust + WebAssembly. Supports server side rendering.
Stars: ✭ 1,856 (+14.71%)
Mutual labels:  frontend

Login Flow

This application demonstrates what a React.js based register/login workflow might look like on the Frontend. I used my react-boilerplate as a starting point — the app thus uses Redux, PostCSS, react-router, ServiceWorker, AppCache, bcrypt and lots more.

The default username is AzureDiamond and the default password is hunter2, but feel free to register new users! The registered users are saved to localStorage, so they'll persist across page reloads.


Authentication

Everything authentication related is collected in the js/utils folder. The actual auth happens in auth.js, using fakeRequest.js and fakeServer.js.

fakeRequest is a fake XMLHttpRequest wrapper with a syntax similar to request.js. It simulates network latency too, so loading states are visible. fakeServer responds to the fake HTTP requests and pretends to be a real server, storing the current users in localStorage with the passwords encrypted using bcrypt.

To change it to real authentication, you’d only have to import request.js instead of fakeRequest.js and it should work! (Provided you have a server somewhere and the endpoints configured)

Features

  • Using react-hot-loader, your changes in the CSS and JS get reflected in the app instantly without refreshing the page. That means that the current application state persists even when you change something in the underlying code! For a very good explanation and demo watch Dan Abramov himself talking about it at react-europe.

  • Redux is a much better implementation of a flux–like, unidirectional data flow. Redux makes actions composable, reduces the boilerplate code and makes hot–reloading possible in the first place. For a good overview of redux check out the talk linked above or the official documentation!

  • PostCSS is like Sass, but modular and capable of much more. PostCSS is, in essence, just a wrapper for plugins which exposes an easy to use, but very powerful API. While it is possible to replicate Sass features with PostCSS, PostCSS has an ecosystem of amazing plugins with functionalities Sass cannot even dream about having.

  • react-router is used for routing in this application. react-router makes routing really easy to do and takes care of a lot of the work.

  • ServiceWorker and AppCache make it possible to use the application offline. As soon as the website has been opened once, it is cached and available without a network connection. manifest.json is specifically for Chrome on Android. Users can add the website to the homescreen and use it like a native app!

Getting started

  1. Clone this repo using git clone [email protected]:mxstbr/login-flow.

  2. Run npm install to install the dependencies.

  3. Run npm start to start the local web server.

  4. Go to http://localhost:3000 and you should see the app running!

CSS

The CSS modules found in the css subfolders all get imported into the main.css file, which get inlined and minified into the compiled.css file. To add/change the styling, either write the CSS into the appropriate module or make a new one and @import it in the main.css file at the appropriate place.

PostCSS Plugins

The boilerplate uses PostCSS, and includes a few plugins by default:

  • postcss-import: Inlines @imported stylesheets to create one big stylesheet.

  • postcss-simple-vars: Makes it possible to use `$variables in your CSS.

  • postcss-focus: Adds a :focus selector to every :hover.

  • autoprefixer-core: Prefixes your CSS automatically, supporting the last two versions of all major browsers and IE 8 and up.

  • cssnano: Optimizes your CSS file. For a full list of optimizations check the official website.

  • postcss-reporter: Makes warnings by the above plugins visible in the console.

For a full, searchable catalog of plugins go to postcss.parts.

Folder Structure

The boilerplate comes with a basic folder structure to keep the CSS files organised. This is what the folders are for:

  • base: Global styling, e.g. setting the box–model for all elements

  • components: Component specific styling, e.g. buttons, modals,...

  • layout: Global layouts, e.g. article, homepage,...

  • utils: Utility files, e.g. variables, mixins, functions,...

  • vendor: External files, e.g. a CSS reset

JS

All files that are imported/required somewhere get compiled into one big file at build time. (build/bundle.js) Webpack automatically optimizes your JavaScript with UglifyJS, so you do not have to worry about that.

Folder Structure

The folder structure of the JS files reflects how Redux works, so if you are not familiar with Redux check out the official documentation.

  • actions: Actions get dispatched with this/these utility module(s)

  • components: The main JS folder. All the React components are in this folder, with pages (routes) saved in the pages subfolder. E.g. a navigation component Nav.react.js

  • constants: Action constants are defined in this/these utility module(s)

  • reducers: Reducers manage the state of this app, basically a simplified implementation of Stores in Flux. For an introduction to reducers, watch this talk by @gaearon.

  • utils: Utility files.

Authentication

Authentication happens in js/utils/auth.js, using fakeRequest.js and fakeServer.js. fakeRequest is a fake XMLHttpRequest wrapper with a similar syntax to request.js which simulates network latency. fakeServer responds to the fake HTTP requests and pretends to be a real server, storing the current users in localStorage with the passwords encrypted using bcrypt. To change it to real authentication, you'd only have to import request.js instead of fakeRequest.js and have a server running somewhere.

Opinionated features

Web Fonts

If you simply use web fonts in your project, the page will stay blank until these fonts are downloaded. That means a lot of waiting time in which users could already read the content.

FontFaceObserver adds a js-<font-name>-loaded class to the body when the fonts have loaded. You should specify an initial font-family with save fonts, and a .js-<font-name>-loaded font-family which includes your web font.

Adding a new font

  1. Add the @font-face declaration to base/_fonts.css.

  2. In base/_base.css, specify your initial font-family in the body tag with only save fonts. In the body.js-<font-name>-loaded tag, specify your font-family stack with your web font.

  3. In js/app.js add a <font-name>Observer for your font.

Offline access

Using a ServiceWorker and the AppCache, the application is cached for offline usage. To cache a file, add it to the urlsToCache variable in the serviceworker.js file.

Once you run locally you will need to terminate the serviceworker when running another app in the same localhost port, to terminate the serviceworker visit chrome://inspect/#service-workers find the path to your localhost and terminate the worker. You might need to stop the worker if terminating wasn't enough chrome://serviceworker-internals then find the path to your localhost and stop/unregister.

Add To Homescreen

On Chrome for Android (soon hopefully more browsers), users can add a webpage to the homescreen. Combined with offline caching, this means the app can be used exactly like a native application.

Gotchas

These are some things to be aware of when using this boilerplate.

Images in the HTML file(s)

Adding images to the HTML is a bit of a pain right now as webpack only goes through the JavaScript file. Add the image to your HTML file how you always would:

<!-- Normal Image -->
<img src="img/yourimg.png" />
<!-- Meta tags -->
<meta property="og:image" content="img/yourimg.png" />
<!-- ... -->

If you simply do this, webpack will not transfer the images to the build folder. To get webpack to transfer them, you have to import them with the file loader in your JavaScript somewhere, e.g.:

import 'file?name=[name].[ext]!../img/yourimg.png';

Then webpack will correctly transfer the image to the build folder.

License

This project is licensed under the MIT license, Copyright (c) 2015 Maximilian Stoiber. For more information see LICENSE.md.

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].