Best JavaScript code snippet using argos
test_logout.py
Source:test_logout.py
...84 expected = {85 'target': '/',86 }87 self.assertDictContainsSubset(expected, response.context_data)88 def test_client_logout(self):89 """ Verify the context includes a list of the logout URIs of the authenticated OpenID Connect clients.90 The list should only include URIs of the clients for which the user has been authenticated.91 """92 client = self._create_oauth_client()93 response = self._assert_session_logged_out(client)94 expected = {95 'logout_uris': [],96 'target': '/',97 }98 self.assertDictContainsSubset(expected, response.context_data)99 @mock.patch(100 'django.conf.settings.IDA_LOGOUT_URI_LIST',101 ['http://fake.ida1/logout', 'http://fake.ida2/accounts/logout', ]102 )...
logout.py
Source:logout.py
...57 # We do not log here, because we have a handler registered to perform logging on successful logouts.58 request.is_from_logout = True59 # Get third party auth provider's logout url60 self.tpa_logout_url = tpa_pipeline.get_idp_logout_url_from_running_pipeline(request)61 logout(request)62 response = super().dispatch(request, *args, **kwargs)63 # Clear the cookie used by the edx.org marketing site64 delete_logged_in_cookies(response)65 return response66 def _build_logout_url(self, url):67 """68 Builds a logout URL with the `no_redirect` query string parameter.69 Args:70 url (str): IDA logout URL71 Returns:72 str73 """74 scheme, netloc, path, query_string, fragment = urlsplit(url)75 query_params = parse_qs(query_string)...
LogoutComponent.js
Source:LogoutComponent.js
1/**2 * Created by Andy Likuski on 2020.09.113 * Copyright (c) 2020 Andy Likuski4 *5 * Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:6 *7 * The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.8 *9 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.10 */11import * as R from 'ramda';12import * as ReactRouterDom from "react-router-dom";13import {14 componentAndPropsFor,15 composeViews,16 e,17 nameLookup,18 propsFor,19 renderChoicepoint,20 renderErrorDefault,21 renderLoadingDefault22} from '@rescapes/helpers-component';23import PropTypes from 'prop-types';24import * as RR from '@rescapes/ramda';25import {defaultNode} from '@rescapes/ramda';26import LogoutButtonComponent from './LogoutButtonComponent.js';27import {AuthenticationBox} from '../themeComponents/authenticationBox';28const {strPathOr, reqStrPathThrowing, strPathOrNullOk} = RR;29const {Redirect, useHistory, useLocation} = defaultNode(ReactRouterDom)30export const c = nameLookup({31 logout: true,32 logoutHeader: true,33 logoutBody: true,34 logoutButton: true,35 logoutLoading: true,36 logoutError: true37});38export default function LogoutComponent(props) {39 // Browser history hook40 const history = useHistory();41 // Browser location hook42 const location = useLocation();43 const allProps = LogoutComponent.views(R.mergeRight(props, {history, location}));44 const propsOf = propsFor(allProps.views);45 return e('div', propsOf(c.logout),46 LogoutComponent.choicepoint(allProps)47 );48}49/**50 *51 * @param {Object} history History object from the useHistory hook52 * @param {Object} location Location object from the useLocation hook53 * @param {Object} queryAuthenticatedUserLocalContainer Apollo query result about state of the user54 * @param views55 * @returns {Object}56 */57LogoutComponent.renderData = ({history, location, mutateDeleteTokenCookie, views}) => {58 const styledComponentAndProps = componentAndPropsFor(views);59 const propsOf = propsFor(views);60 // TODO Since refetchQueries doesn't work well (https://github.com/apollographql/apollo-client/issues/3633)61 // just listen to the result of the mutation and redirect to the referring page or /62 // Ideally we shouldn't have to redirect because the AppContainer's queries should rerun when the token goes63 // is the cache, but I don't know how to get a cache write to trigger dependent queries.64 if (strPathOr(false, 'result.data.deleteTokenCookie', mutateDeleteTokenCookie)) {65 return e(Redirect, {to: '/login'});66 }67 return e(AuthenticationBox, propsOf(c.logoutBody), [68 e('h2', propsOf(c.logoutHeader)),69 e(LogoutButtonComponent, propsOf(c.logoutButton))70 ]);71};72/**73 * Merges parent and state styles into component styles74 * @param style75 */76LogoutComponent.viewStyles = ({style}) => {77 return {78 [c.logout]: {},79 [c.logoutButton]: {},80 [c.logoutBody]: {}81 };82};83LogoutComponent.viewProps = props => {84 return {85 [c.logout]: {},86 [c.logoutBody]: {87 },88 [c.logoutButton]: {89 children: 'Logout'90 }91 };92};93LogoutComponent.viewEventHandlers = props => {94 return {95 [c.logoutButton]: {96 onClick: () => {97 reqStrPathThrowing('mutateDeleteTokenCookie.mutation', props)({98 variables: {}99 });100 }101 }102 };103};104/**105 * Adds to props.views for each component configured in viewEventHandlers, viewProps, and viewStyles106 * @param {Object} props this.props or equivalent for testing107 * @returns {Object} modified props108 */109LogoutComponent.views = composeViews(110 LogoutComponent.viewEventHandlers,111 LogoutComponent.viewProps,112 LogoutComponent.viewStyles113);114/**115 * Loading, Error, or Data based on the props.116 */117LogoutComponent.choicepoint = p => {118 return renderChoicepoint(119 {120 onError: renderErrorDefault(c.logoutError),121 onLoading: renderLoadingDefault(c.logoutLoading),122 onData: LogoutComponent.renderData123 },124 {}125 )(p);126};127LogoutComponent.propTypes = {128 style: PropTypes.shape().isRequired...
saveJS.js
Source:saveJS.js
1// $(document).ready(function () {2$('#savetoDB').on('click', function () {3 let name = localStorage.getItem('charName');4 let race = localStorage.getItem('charRace');5 let charClass = localStorage.getItem('charClass');6 let charGender = localStorage.getItem('charGender');7 let charID = localStorage.getItem('charID');8 console.log(charID);9 if (charID === null) {10 createUserChar(name, race, charClass, charGender);11 } else {12 updateUserChar(name, race, charClass, charGender, charID);13 }14});15$(document).foundation();16//Logout button clears localstorage so a new user can login17$('#logout').on('click', function () {18 event.preventDefault();19 // $(document).foundation();20 //CREATES MODAL21 // create a div for the modal22 var logoutModal = $('<div>');23 // add class and ID for modal24 $(logoutModal).addClass('reveal revealStyle');25 $(logoutModal).attr('id', 'logoutModal');26 $(logoutModal).attr('data-reveal', '');27 // append the modal div to mainbody28 $('#mainBody').append(logoutModal);29 //LOGOUT MODAL TITLE30 var logoutTitle = $('<h1>');31 $(logoutTitle).text('Wait!');32 $(logoutModal).append(logoutTitle);33 //LOGOUT EXPLAINED34 var logoutDesc1 = $('<p>');35 $(logoutDesc1).text('Have you saved your character?');36 var logoutDesc2 = $('<p>');37 $(logoutDesc2).text(38 'If you would like to save your character for the next time you use DnD Buddy you will need to click on Save and Logout; otherwise click on Logout without Saving or Cancel.'39 );40 $(logoutModal).append(logoutDesc1);41 $(logoutModal).append(logoutDesc2);42 // LOGOUT BUTTONS43 let logoutBtn1 = $('<a>', {44 text: 'Save and Logout',45 class: 'btn btn-primary logout-button',46 id: 'logout1',47 href: '/logout',48 click: function () {49 let name = localStorage.getItem('charName');50 let race = localStorage.getItem('charRace');51 let charClass = localStorage.getItem('charClass');52 let charGender = localStorage.getItem('charGender');53 let charID = localStorage.getItem('charID');54 console.log(charID);55 if (charID === null) {56 createUserChar(name, race, charClass, charGender);57 } else {58 updateUserChar(name, race, charClass, charGender, charID);59 }60 localStorage.clear();61 // $('logout1').attr('href', '/logout');62 // $('logout1').click();63 $('#logoutModal').foundation('close');64 },65 });66 let logoutBtn2 = $('<a>', {67 text: 'Logout without Saving',68 class: 'btn btn-primary logout-button',69 id: 'logout2',70 href: '/logout',71 click: function () {72 localStorage.clear();73 $('#logoutModal').foundation('close');74 },75 });76 let logoutBtn3 = $('<a>', {77 text: 'Cancel',78 class: 'btn btn-primary logout-button',79 id: 'logout3',80 click: function () {81 $('#logoutModal').foundation('close');82 },83 });84 $(logoutModal).append(logoutBtn1);85 $(logoutModal).append(logoutBtn2);86 $(logoutModal).append(logoutBtn3);87 $(document).foundation();88 $('#logoutModal').foundation('open');89});90// update the user data with the existing character91function updateUserChar(name, race, charClass, charGender, charID) {92 $.ajax({93 url: '/api/save',94 type: 'PUT',95 data: {96 char_name: name,97 race: race,98 char_class: charClass,99 char_gender: charGender,100 char_id: charID,101 },102 });103}104// save the data to the database for a new character105function createUserChar(name, race, charClass, charGender, charID) {106 $.ajax({107 url: '/api/saveANewChar',108 type: 'POST',109 data: {110 char_name: name,111 race: race,112 char_class: charClass,113 char_gender: charGender,114 },115 });116}...
index.js
Source:index.js
1'use strict';2const Code = require('code');3const Constants = require('../../../../../client/pages/login/constants');4const Lab = require('lab');5const Proxyquire = require('proxyquire');6const React = require('react');7const ReactDOM = require('react-dom');8const ReactTestUtils = require('react-addons-test-utils');9const Store = require('../../../../../client/pages/login/logout/store');10const lab = exports.lab = Lab.script();11const stub = {12 Actions: {13 logout: function () {}14 }15};16const Logout = Proxyquire('../../../../../client/pages/login/logout/index.jsx', {17 '../actions': stub.Actions18});19lab.experiment('Login Logout Form', () => {20 lab.test('it renders', (done) => {21 const LogoutEl = React.createElement(Logout, {});22 const logout = ReactTestUtils.renderIntoDocument(LogoutEl);23 Code.expect(logout).to.exist();24 done();25 });26 lab.test('it handles unmounting', (done) => {27 const container = global.document.createElement('div');28 const LogoutEl = React.createElement(Logout, {});29 ReactDOM.render(LogoutEl, container);30 ReactDOM.unmountComponentAtNode(container);31 done();32 });33 lab.test('it handles a store change', (done) => {34 const LogoutEl = React.createElement(Logout, {});35 const logout = ReactTestUtils.renderIntoDocument(LogoutEl);36 Store.dispatch({37 type: Constants.LOGOUT38 });39 Code.expect(logout.state.loading).to.be.true();40 done();41 });42 lab.test('it renders with success state', (done) => {43 const LogoutEl = React.createElement(Logout, {});44 const logout = ReactTestUtils.renderIntoDocument(LogoutEl);45 Store.dispatch({46 type: Constants.LOGOUT_RESPONSE,47 err: null48 });49 const alerts = ReactTestUtils.scryRenderedDOMComponentsWithClass(logout, 'alert-success');50 Code.expect(alerts).to.have.length(1);51 done();52 });53 lab.test('it renders with error state', (done) => {54 const LogoutEl = React.createElement(Logout, {});55 const logout = ReactTestUtils.renderIntoDocument(LogoutEl);56 Store.dispatch({57 type: Constants.LOGOUT_RESPONSE,58 err: new Error('sorry pal'),59 response: {60 message: 'major fail'61 }62 });63 const alerts = ReactTestUtils.scryRenderedDOMComponentsWithClass(logout, 'alert-warning');64 Code.expect(alerts).to.have.length(1);65 done();66 });...
urls.py
Source:urls.py
1# -*- coding: utf-8 -*-2"""3Provides basic set of auth urls.4"""5from django.conf.urls.defaults import *6from django.conf import settings7urlpatterns = patterns('')8LOGIN = '^%s$' % settings.LOGIN_URL.lstrip('/')9LOGOUT = '^%s$' % settings.LOGOUT_URL.lstrip('/')10# If user set a LOGOUT_REDIRECT_URL we do a redirect.11# Otherwise we display the default template.12LOGOUT_DATA = {'next_page': getattr(settings, 'LOGOUT_REDIRECT_URL', None)}13# register auth urls depending on whether we use google or hybrid auth14if 'ragendja.auth.middleware.GoogleAuthenticationMiddleware' in \15 settings.MIDDLEWARE_CLASSES:16 urlpatterns += patterns('',17 url(LOGIN, 'ragendja.auth.views.google_login',18 name='django.contrib.auth.views.login'),19 url(LOGOUT, 'ragendja.auth.views.google_logout', LOGOUT_DATA,20 name='django.contrib.auth.views.logout'),21 )22elif 'ragendja.auth.middleware.HybridAuthenticationMiddleware' in \23 settings.MIDDLEWARE_CLASSES:24 urlpatterns += patterns('',25 url(LOGIN, 'ragendja.auth.views.hybrid_login',26 name='django.contrib.auth.views.login'),27 url(LOGOUT, 'ragendja.auth.views.hybrid_logout', LOGOUT_DATA,28 name='django.contrib.auth.views.logout'),29 )30# When faking a real function we always have to add the real function, too.31urlpatterns += patterns('',32 url(LOGIN, 'django.contrib.auth.views.login'),33 url(LOGOUT, 'django.contrib.auth.views.logout', LOGOUT_DATA,),...
Using AI Code Generation
1var argosy = require("argosy");2var argosyPattern = require("argosy-pattern");3var argosyPatterns = require("argosy-patterns");4var argosyService = require("argosy-service");5var argosyWeb = require("argosy-web");6var service = argosy();7service.use(argosyService({8 logout: argosyPattern({9 })10}, function (request, callback) {11}));12service.use(argosyWeb({13}));14 var argosy = window.argosy;15 var service = argosy();16 service.use(argosyService({17 logout: argosyPattern({18 })19 }, function (request, callback) {20 }));21 service.use(argosyWeb({22 }));23var argosy = require("argosy");24var argosyWeb = require("argosy-web");25var service = argosy();26service.use(argosyWeb({27}));28 var argosy = window.argosy;29 var service = argosy();30 service.use(argosyWeb({31 }));32var argosyPattern = require("argosy-pattern");33var pattern = argosyPattern({34});35pattern.matches({36pattern.matches({37pattern.matches({38pattern.matches({
Using AI Code Generation
1var logout = require('argos-sdk/src/Logout');2logout();3var login = require('argos-sdk/src/Login');4login();5var request = require('argos-sdk/src/Request');6request();7See [CONTRIBUTING.md](CONTRIBUTING.md)8See [LICENSE](LICENSE)
Using AI Code Generation
1var argosy = require('argosy')2var logout = require('./logout')3var myArgosy = argosy()4myArgosy.pipe(logout()).pipe(myArgosy)5myArgosy.accept({logout:logout.logout})6var argosy = require('argosy')7var logout = require('./logout')8var myArgosy = argosy()9myArgosy.pipe(logout()).pipe(myArgosy)10myArgosy.accept({logout:logout.logout})11var argosy = require('argosy')12var logout = require('./logout')13var myArgosy = argosy()14myArgosy.pipe(logout()).pipe(myArgosy)15myArgosy.accept({logout:logout.logout})16var argosy = require('argosy')17var logout = require('./logout')18var myArgosy = argosy()19myArgosy.pipe(logout()).pipe(myArgosy)20myArgosy.accept({logout:logout.logout})21var argosy = require('argosy')22var logout = require('./logout')23var myArgosy = argosy()24myArgosy.pipe(logout()).pipe(myArgosy)25myArgosy.accept({logout:logout.logout})26var argosy = require('argosy')27var logout = require('./logout')28var myArgosy = argosy()29myArgosy.pipe(logout()).pipe(myArgosy)30myArgosy.accept({logout:logout.logout})31var argosy = require('argosy')32var logout = require('./logout')33var myArgosy = argosy()34myArgosy.pipe(logout()).pipe(myArgosy)35myArgosy.accept({logout:logout.logout})36var argosy = require('
Using AI Code Generation
1var argosAuth = require('argos-auth');2argosAuth.logout();3var argosAuth = require('argos-auth');4argosAuth.isLoggedIn();5var argosAuth = require('argos-auth');6argosAuth.login('username', 'password');7var argosAuth = require('argos-auth');8argosAuth.isLoggedIn();9var argosAuth = require('argos-auth');10argosAuth.login('username', 'password');11var argosAuth = require('argos-auth');12argosAuth.isLoggedIn();13var argosAuth = require('argos-auth');14argosAuth.login('username', 'password');15var argosAuth = require('argos-auth');16argosAuth.isLoggedIn();17var argosAuth = require('argos-auth');18argosAuth.login('username', 'password');19var argosAuth = require('argos-auth');20argosAuth.isLoggedIn();21var argosAuth = require('argos-auth');22argosAuth.login('username', 'password');23var argosAuth = require('argos-auth');24argosAuth.isLoggedIn();25var argosAuth = require('argos-auth');26argosAuth.login('username', 'password');27var argosAuth = require('argos-auth');28argosAuth.isLoggedIn();29var argosAuth = require('argos-auth');30argosAuth.login('username', 'password');
Using AI Code Generation
1var logout = require('argos-sdk').logout;2var logout = require('argos-sdk').logout;3logout().then(function() {4 console.log('User logged out');5}).catch(function(error) {6 console.log('Error logging out user');7});8var logout = require('argos-sdk').logout;9logout().then(function() {10 console.log('User logged out');11}).catch(function(error) {12 console.log('Error logging out user');13});14var logout = require('argos-sdk').logout;15logout().then(function() {16 console.log('User logged out');17}).catch(function(error) {18 console.log('Error logging out user');19});20var logout = require('argos-sdk').logout;21logout().then(function() {22 console.log('User logged out');23}).catch(function(error) {24 console.log('Error logging out user');25});26var logout = require('argos-sdk').logout;27logout().then(function() {28 console.log('User logged out');29}).catch(function(error) {30 console.log('Error logging out user');31});32var logout = require('argos-sdk').logout;33logout().then(function() {34 console.log('User logged out');35}).catch(function(error) {36 console.log('Error logging out user');37});38var logout = require('argos-sdk').logout;39logout().then(function() {40 console.log('User logged out');41}).catch(function(error) {42 console.log('Error logging out user');43});44var logout = require('argos-sdk').logout;45logout().then(function() {46 console.log('User logged out');47}).catch(function(error) {48 console.log('Error logging out user');49});50var logout = require('argos-sdk').logout;51logout().then(function() {52 console.log('User
Using AI Code Generation
1var argosy = require('argosy');2var logout = require('argosy-patterns/logout')();3var patterns = require('argosy-patterns');4var logoutService = logout(function (logoutRequest, cb) {5 cb(null, 'ok');6});7var argosy = argosy();8argosy.accept(logoutService);9argosy.pipe(argosy).pipe(argosy);10var argosy = require('argosy');11var patterns = require('argosy-patterns');12var argosy = argosy();13argosy.use(patterns.logout());14argosy.on('logout', function () {15});16var argosy = require('argosy');17var patterns = require('argosy-patterns');18var argosy = argosy();19argosy.use(patterns.logout());20argosy.on('logout', function () {21});22var argosy = require('argosy');23var patterns = require('argosy-patterns');24var argosy = argosy();25argosy.use(patterns.logout());26argosy.on('logout', function () {27});28var argosy = require('argosy');29var patterns = require('argosy-patterns');30var argosy = argosy();31argosy.use(patterns.logout());32argosy.on('logout', function () {33});34var argosy = require('argosy');35var patterns = require('argosy-patterns');36var argosy = argosy();37argosy.use(patterns.logout());38argosy.on('logout', function () {39});40var argosy = require('argosy');41var patterns = require('argosy-patterns');42var argosy = argosy();43argosy.use(patterns.logout());44argosy.on('logout', function () {45});
Learn to execute automation testing from scratch with LambdaTest Learning Hub. Right from setting up the prerequisites to run your first automation test, to following best practices and diving deeper into advanced test scenarios. LambdaTest Learning Hubs compile a list of step-by-step guides to help you be proficient with different test automation frameworks i.e. Selenium, Cypress, TestNG etc.
You could also refer to video tutorials over LambdaTest YouTube channel to get step by step demonstration from industry experts.
Get 100 minutes of automation test minutes FREE!!