Skip to content
This repository has been archived by the owner on Jun 3, 2024. It is now read-only.

Commit

Permalink
Merge pull request #388 from plotly/logout-btn
Browse files Browse the repository at this point in the history
Add Logout button
  • Loading branch information
T4rk1n committed Nov 29, 2018
2 parents 6558624 + 640f4b1 commit 074bca8
Show file tree
Hide file tree
Showing 15 changed files with 2,908 additions and 2,546 deletions.
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,10 @@
All notable changes to this project will be documented in this file.
This project adheres to [Semantic Versioning](http://semver.org/).

## [0.40.0] - 2018-11-28
### Added
- Add Logout button (dash-deployment-server authentication integration) [#388](https://github.com/plotly/dash-core-components/pull/388)

## [0.39.0] - 2018-11-12
### Changed
- Updated `react` and `react-dom` to version `^16.6.1`
Expand Down
81 changes: 81 additions & 0 deletions dash_core_components/LogoutButton.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,81 @@
# AUTO GENERATED FILE - DO NOT EDIT

from dash.development.base_component import Component, _explicitize_args


class LogoutButton(Component):
"""A LogoutButton component.
Logout button to submit a form post request to the `logout_url` prop.
Usage is intended for dash-deployment-server authentication.
DDS usage:
`dcc.LogoutButton(logout_url=os.getenv('DASH_LOGOUT_URL'))`
Custom usage:
- Implement a login mechanism.
- Create a flask route with a post method handler.
`@app.server.route('/logout', methods=['POST'])`
- The logout route should perform what's necessary for the user to logout.
- If you store the session in a cookie, clear the cookie:
`rep = flask.Response(); rep.set_cookie('session', '', expires=0)`
- Create a logout button component and assign it the logout_url
`dcc.LogoutButton(logout_url='/logout')`
See https://dash.plot.ly/dash-core-components/logout_button
for more documentation and examples.
Keyword arguments:
- id (string; optional): Id of the button.
- label (string; optional): Text of the button
- logout_url (string; optional): Url to submit a post logout request.
- style (dict; optional): Style of the button
- method (string; optional): Http method to submit the logout form.
- className (string; optional): CSS class for the button.
Available events: """
@_explicitize_args
def __init__(self, id=Component.UNDEFINED, label=Component.UNDEFINED, logout_url=Component.UNDEFINED, style=Component.UNDEFINED, method=Component.UNDEFINED, className=Component.UNDEFINED, **kwargs):
self._prop_names = ['id', 'label', 'logout_url', 'style', 'method', 'className']
self._type = 'LogoutButton'
self._namespace = 'dash_core_components'
self._valid_wildcard_attributes = []
self.available_events = []
self.available_properties = ['id', 'label', 'logout_url', 'style', 'method', 'className']
self.available_wildcard_properties = []

_explicit_args = kwargs.pop('_explicit_args')
_locals = locals()
_locals.update(kwargs) # For wildcard attrs
args = {k: _locals[k] for k in _explicit_args if k != 'children'}

for k in []:
if k not in args:
raise TypeError(
'Required argument `' + k + '` was not specified.')
super(LogoutButton, self).__init__(**args)

def __repr__(self):
if(any(getattr(self, c, None) is not None
for c in self._prop_names
if c is not self._prop_names[0])
or any(getattr(self, c, None) is not None
for c in self.__dict__.keys()
if any(c.startswith(wc_attr)
for wc_attr in self._valid_wildcard_attributes))):
props_string = ', '.join([c+'='+repr(getattr(self, c, None))
for c in self._prop_names
if getattr(self, c, None) is not None])
wilds_string = ', '.join([c+'='+repr(getattr(self, c, None))
for c in self.__dict__.keys()
if any([c.startswith(wc_attr)
for wc_attr in
self._valid_wildcard_attributes])])
return ('LogoutButton(' + props_string +
(', ' + wilds_string if wilds_string != '' else '') + ')')
else:
return (
'LogoutButton(' +
repr(getattr(self, self._prop_names[0], None)) + ')')
7 changes: 4 additions & 3 deletions dash_core_components/_imports_.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
from .Interval import Interval
from .Link import Link
from .Location import Location
from .LogoutButton import LogoutButton
from .Markdown import Markdown
from .RadioItems import RadioItems
from .RangeSlider import RangeSlider
Expand All @@ -20,7 +21,6 @@
from .Textarea import Textarea
from .Upload import Upload


__all__ = [
"Checklist",
"ConfirmDialog",
Expand All @@ -33,6 +33,7 @@
"Interval",
"Link",
"Location",
"LogoutButton",
"Markdown",
"RadioItems",
"RangeSlider",
Expand All @@ -42,5 +43,5 @@
"Tab",
"Tabs",
"Textarea",
"Upload",
]
"Upload"
]
88 changes: 61 additions & 27 deletions dash_core_components/dash_core_components.dev.js

Large diffs are not rendered by default.

12 changes: 6 additions & 6 deletions dash_core_components/dash_core_components.min.js

Large diffs are not rendered by default.

Loading

0 comments on commit 074bca8

Please sign in to comment.