{"id":13394614,"url":"https://github.com/mxstbr/login-flow","last_synced_at":"2025-05-16T06:00:25.204Z","repository":{"id":83297887,"uuid":"48028972","full_name":"mxstbr/login-flow","owner":"mxstbr","description":":key: A login/register flow built with React\u0026Redux","archived":false,"fork":false,"pushed_at":"2017-04-10T21:08:56.000Z","size":146,"stargazers_count":1597,"open_issues_count":17,"forks_count":214,"subscribers_count":45,"default_branch":"master","last_synced_at":"2025-05-15T14:16:13.733Z","etag":null,"topics":["authentication","frontend","login-flow","react","redux"],"latest_commit_sha":null,"homepage":"https://loginflow.mxstbr.com","language":"JavaScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/mxstbr.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE.md","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2015-12-15T08:14:01.000Z","updated_at":"2025-04-04T13:35:59.000Z","dependencies_parsed_at":"2023-03-12T17:54:39.902Z","dependency_job_id":null,"html_url":"https://github.com/mxstbr/login-flow","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mxstbr%2Flogin-flow","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mxstbr%2Flogin-flow/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mxstbr%2Flogin-flow/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mxstbr%2Flogin-flow/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/mxstbr","download_url":"https://codeload.github.com/mxstbr/login-flow/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":254478160,"owners_count":22077675,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["authentication","frontend","login-flow","react","redux"],"created_at":"2024-07-30T17:01:25.572Z","updated_at":"2025-05-16T06:00:25.175Z","avatar_url":"https://github.com/mxstbr.png","language":"JavaScript","funding_links":[],"categories":["JavaScript"],"sub_categories":[],"readme":"# Login Flow\n\nThis application demonstrates what a React.js based register/login workflow might look like on the Frontend. I used my [react-boilerplate](https://github.com/mxstbr/react-boilerplate) as a starting point — the app thus uses  Redux, PostCSS, react-router, ServiceWorker, AppCache, bcrypt and lots more.\n\nThe 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.\n\n-----\n\n## Authentication\n\nEverything authentication related is collected in the [`js/utils`](js/utils) folder. The actual auth happens in [`auth.js`](js/utils/auth.js), using [`fakeRequest.js`](js/utils/fakeRequest.js) and [`fakeServer.js`](js/utils/fakeServer.js).\n\n`fakeRequest` is a fake XMLHttpRequest wrapper with a syntax similar to [`request.js`](https://github.com/request/request). 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`.\n\nTo 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)*\n\n## Features\n\n- Using [**react-hot-loader**](https://github.com/gaearon/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](https://www.youtube.com/watch?v=xsSnOQynTHs).\n\n- [**Redux**](https://github.com/rackt/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](https://gaearon.github.io/redux/)!\n\n- [**PostCSS**](https://github.com/postcss/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](https://github.com/jonathantneal/precss) with PostCSS, PostCSS has an [ecosystem of amazing plugins](http://postcss.parts) with functionalities Sass cannot even dream about having.\n\n- [**react-router**](https://github.com/rackt/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.\n\n- [**ServiceWorker**](http://www.html5rocks.com/en/tutorials/service-worker/introduction/) and [**AppCache**](http://www.html5rocks.com/en/tutorials/appcache/beginner/) 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`**](https://developer.chrome.com/multidevice/android/installtohomescreen) is specifically for Chrome on Android. Users can add the website to the homescreen and use it like a native app!\n\n## Getting started\n\n1. Clone this repo using `git clone git@github.com:mxstbr/login-flow`.\n\n2. Run `npm install` to install the dependencies.\n\n3. Run `npm start` to start the local web server.\n\n4. Go to `http://localhost:3000` and you should see the app running!\n\n## CSS\n\nThe 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.\n\n### PostCSS Plugins\n\nThe boilerplate uses PostCSS, and includes a few plugins by default:\n\n* `postcss-import`: Inlines `@import`ed stylesheets to create one big stylesheet.\n\n* `postcss-simple-vars`: Makes it possible to use `$variables in your CSS.\n\n* `postcss-focus`: Adds a `:focus` selector to every `:hover`.\n\n* `autoprefixer-core`: Prefixes your CSS automatically, supporting the last two versions of all major browsers and IE 8 and up.\n\n* `cssnano`: Optimizes your CSS file. For a full list of optimizations check [the official website](http://cssnano.co/optimisations/).\n\n* `postcss-reporter`: Makes warnings by the above plugins visible in the console.\n\nFor a full, searchable catalog of plugins go to [postcss.parts](http://postcss.parts).\n\n### Folder Structure\n\nThe boilerplate comes with a basic folder structure to keep the CSS files organised. This is what the folders are for:\n\n* `base`: Global styling, e.g. setting the box–model for all elements\n\n* `components`: Component specific styling, e.g. buttons, modals,...\n\n* `layout`: Global layouts, e.g. article, homepage,...\n\n* `utils`: Utility files, e.g. variables, mixins, functions,...\n\n* `vendor`: External files, e.g. a CSS reset\n\n## JS\n\nAll files that are `import`ed/`require`d 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.\n\n### Folder Structure\n\nThe folder structure of the JS files reflects how [Redux](https://github.com/gaearon/redux) works, so if you are not familiar with Redux check out the [official documentation](https://gaearon.github.io/redux/).\n\n* `actions`: Actions get dispatched with this/these utility module(s)\n\n* `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`\n\n* `constants`: Action constants are defined in this/these utility module(s)\n\n* `reducers`: Reducers manage the state of this app, basically a simplified implementation of Stores in Flux. For an introduction to reducers, watch [this talk](https://www.youtube.com/watch?v=xsSnOQynTHs) by @gaearon.\n\n* `utils`: Utility files.\n\n### Authentication\n\nAuthentication 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`.\nTo change it to real authentication, you'd only have to import `request.js` instead of `fakeRequest.js` and have a server running somewhere.\n\n## Opinionated features\n\n### Web Fonts\n\nIf 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.\n\n[FontFaceObserver](https://github.com/bramstein/fontfaceobserver) adds a `js-\u003cfont-name\u003e-loaded` class to the `body` when the fonts have loaded. You should specify an initial `font-family` with save fonts, and a `.js-\u003cfont-name\u003e-loaded` `font-family` which includes your web font.\n\n#### Adding a new font\n\n1. Add the `@font-face` declaration to `base/_fonts.css`.\n\n2. In `base/_base.css`, specify your initial `font-family` in the `body` tag with only save fonts. In the `body.js-\u003cfont-name\u003e-loaded` tag, specify your `font-family` stack with your web font.\n\n3. In `js/app.js` add a `\u003cfont-name\u003eObserver` for your font.\n\n### Offline access\n\nUsing 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.\n\nOnce 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.\n\n### Add To Homescreen\n\nOn 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.\n\n## Gotchas\n\nThese are some things to be aware of when using this boilerplate.\n\n### Images in the HTML file(s)\n\nAdding 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:\n\n```HTML\n\u003c!-- Normal Image --\u003e\n\u003cimg src=\"img/yourimg.png\" /\u003e\n\u003c!-- Meta tags --\u003e\n\u003cmeta property=\"og:image\" content=\"img/yourimg.png\" /\u003e\n\u003c!-- ... --\u003e\n```\n\nIf 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.:\n\n```JavaScript\nimport 'file?name=[name].[ext]!../img/yourimg.png';\n```\n\nThen webpack will correctly transfer the image to the build folder.\n\n## License\n\nThis project is licensed under the MIT license, Copyright (c) 2015 Maximilian Stoiber. For more information see `LICENSE.md`.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmxstbr%2Flogin-flow","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fmxstbr%2Flogin-flow","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmxstbr%2Flogin-flow/lists"}