Best Python code snippet using tempest_python
crowdfundly-admin.js
Source:crowdfundly-admin.js
1(function( $ ) {2 'use strict';3 $(document).ready(function() {4 changeToken();5 signUpView();6 authTypeView();7 emailLogInAuth();8 signUpAuth();9 forgetPassword();10 if ( crowdfundlyAuth && crowdfundlyAuth.has_bearer_token ) {11 pre_set_dashboard();12 disconnect_api();13 } else {14 connect_api();15 }16 });17 async function changeToken() {18 const lsToken = localStorage.getItem('auth._token.local');19 if ( ! crowdfundlyAuth || ! lsToken ) return;20 const dbToken = 'Bearer ' + crowdfundlyAuth.bearer_token21 if ( dbToken != lsToken ) {22 await localStorage.setItem('auth._token.local', dbToken);23 await Cookies.set('auth._token.local', dbToken);24 window.location.reload()25 }26 }27 function signUpView() {28 const authType = $('#crowdfundly-auth-type');29 const authTypeText = $('#auth-type-text');30 const signIn = $('#crowdfundly-signin-form');31 const signUp = $('#crowdfundl-signup-form-wrapper');32 const forgetPassword = $('#crowdfundl-forget-password-form-wrapper');33 authType.on('click', function() {34 $(this).toggleClass('sign-in');35 $(this).text($(this).data('sign-in'));36 authTypeText.text(authTypeText.data('sign-up-text'));37 signIn.css('display', 'none');38 signUp.css('display', 'block');39 forgetPassword.css('display', 'none');40 if ( $(this).hasClass('sign-in') ) {41 $(this).text($(this).data('sign-up'));42 authTypeText.text(authTypeText.data('sign-up-text'));43 authTypeText.text(authTypeText.data('sign-in-text'));44 $('#app-key-auth-btn').text($('#app-key-auth-btn').data('key-text'));45 $('#app-key-auth-btn').addClass('email-auth');46 signIn.css('display', 'block');47 signUp.css('display', 'none');48 $('#email-auth').css('display', 'block');49 $('#app-key-auth').css('display', 'none');50 }51 })52 }53 // function signUpValidation() {54 // let errorList = [];55 // // confirm password match validation56 // let signupConfirmPasswordValue = '';57 // $('#signupConfirmPassword').on( 'input', function(e) {58 // const signupPasswordValue = $('#signupPassword').val();59 // signupConfirmPasswordValue = $(this).val();60 // const confirmPassField = $('#confirmPassFieldGroup');61 // if ( signupPasswordValue != '' && signupConfirmPasswordValue != '' ) {62 // if ( signupPasswordValue !== signupConfirmPasswordValue ) {63 // errorList[0] = 'Password didn\'t match...';64 // // console.log("signupPasswordValue !== signupConfirmPasswordValue", errorList);65 // if ( $('.signup-validation.confirm-password').length < 1 ) {66 // confirmPassField.append('<label id="signupConfirmPassCheck-error" class="signup-validation confirm-password">Password didn\'t match...</label>');67 // }68 // } else {69 // errorList = [];70 // // console.log("confirm else", errorList);71 // $('.signup-validation.confirm-password').remove();72 // }73 // }74 // });75 // $('#signupPassword').on( 'input', function(e) {76 // let signupPasswordValue = $('#signupPassword').val();77 // // signupPasswordValue = e.keyCode === 8 ? signupPasswordValue.length - 1 : signupPasswordValue.length + 1;78 // signupConfirmPasswordValue = $('#signupConfirmPassword').val();79 // const passwordFieldGroup = $('#PasswordFieldGroup');80 // const confirmPassField = $('#confirmPassFieldGroup');81 82 // if (signupPasswordValue.length <= 5) {83 // errorList[0] = 'Password must be at least 6 characters.';84 // // console.log("signupPasswordValue.length <= 5", errorList);85 // if ($('.signup-validation.password').length < 1) {86 // passwordFieldGroup.append('<label id="signupPassCheck-error" class="signup-validation password">Password must be at least 6 characters.</label>');87 // }88 // } else {89 // errorList = [];90 // // console.log("else", errorList);91 // $('.signup-validation.password').remove();92 // }93 94 // if ( signupConfirmPasswordValue != '' ) {95 // if ( signupConfirmPasswordValue != signupPasswordValue ) {96 // errorList[0] = 'Password didn\'t match...';97 // // console.log("signupConfirmPasswordValue != signupPasswordValue", errorList);98 // if ( $('.signup-validation.confirm-password').length < 1 ) {99 // confirmPassField.append('<label id="signupConfirmPassCheck-error" class="signup-validation confirm-password">Password didn\'t match...</label>');100 // }101 // } else {102 // // console.log("2n confirm else", errorList);103 // errorList = [];104 // $('.signup-validation.confirm-password').remove();105 // }106 // }107 // });108 // console.log("signUpValidation return", errorList);109 // return errorList;110 // }111 function signUpSubmitAuth() {112 const formData = {};113 formData['name'] = $('#signupFname').val();114 formData['email'] = $('#signupEmail').val();115 formData['password']= $('#signupPassword').val();116 formData['password_confirmation'] = $('#signupConfirmPassword').val();117 formData['type'] = 'regular';118 const emailAuthBtn = $('#crowdfundly-sign-up-btn');119 emailAuthBtn.attr('disabled', true);120 $('.auth-form__loader').css('display', 'block');121 $.ajax({122 type: 'POST',123 url: crowdfundlyAuth.ajax_url,124 data: {125 action: "crowdfundly_signup_auth",126 signupData: formData,127 security: crowdfundlyAuth.nonce,128 },129 success: function (response) {130 // console.log(response);131 if (response.code == 200) {132 swal({133 title: crowdfundlyAuth.success,134 text: "Sign Up Successful",135 icon: 'success'136 });137 }138 setDashboard(response);139 $('.auth-form__loader').css('display', 'none');140 setTimeout(() => {141 window.location.reload();142 }, 1500);143 },144 error: function(error) {145 console.log(error);146 if (error.status === 422) {147 swal({148 title: crowdfundlyAuth.warning,149 text: "The email is already registered with us. Please log in instead.",150 icon: 'warning'151 });152 }153 emailAuthBtn.removeAttr('disabled');154 $('.auth-form__loader').css('display', 'none');155 }156 });157 }158 function signUpAuth() {159 const signUpSubmit = $("#crowdfundly-signup-form");160 const signUpSubmitBtn = $("#crowdfundly-sign-up-btn");161 let errorList = [];162 // confirm password match validation163 let signupConfirmPasswordValue = '';164 $('#signupConfirmPassword').on( 'input', function(e) {165 const signupPasswordValue = $('#signupPassword').val();166 signupConfirmPasswordValue = $(this).val();167 const confirmPassField = $('#confirmPassFieldGroup');168 if ( signupPasswordValue != '' && signupConfirmPasswordValue != '' ) {169 if ( signupPasswordValue !== signupConfirmPasswordValue ) {170 errorList[0] = 'Password didn\'t match...';171 if ( $('.signup-validation.confirm-password').length < 1 ) {172 confirmPassField.append('<label id="signupConfirmPassCheck-error" class="signup-validation confirm-password">Password didn\'t match...</label>');173 }174 } else {175 errorList = [];176 $('.signup-validation.confirm-password').remove();177 }178 }179 });180 $('#signupPassword').on( 'input', function(e) {181 let signupPasswordValue = $('#signupPassword').val();182 signupConfirmPasswordValue = $('#signupConfirmPassword').val();183 const passwordFieldGroup = $('#PasswordFieldGroup');184 const confirmPassField = $('#confirmPassFieldGroup');185 186 if (signupPasswordValue.length <= 5) {187 errorList[0] = 'Password must be at least 6 characters.';188 if ($('.signup-validation.password').length < 1) {189 passwordFieldGroup.append('<label id="signupPassCheck-error" class="signup-validation password">Password must be at least 6 characters.</label>');190 }191 } else {192 errorList = [];193 $('.signup-validation.password').remove();194 }195 196 if ( signupConfirmPasswordValue != '' ) {197 if ( signupConfirmPasswordValue != signupPasswordValue ) {198 errorList[0] = 'Password didn\'t match...';199 if ( $('.signup-validation.confirm-password').length < 1 ) {200 confirmPassField.append('<label id="signupConfirmPassCheck-error" class="signup-validation confirm-password">Password didn\'t match...</label>');201 }202 } else {203 errorList = [];204 $('.signup-validation.confirm-password').remove();205 }206 }207 });208 signUpSubmit.on('submit', function(e) {209 e.preventDefault();210 if ( errorList.length == 0 ) {211 signUpSubmitAuth();212 }213 });214 }215 function emailSubmitAuth() {216 const formData = {};217 formData['email'] = $('#email-login').val();218 formData['password']= $('#password-login').val();219 formData['type'] = 'regular';220 const emailAuthBtn = $('#crowdfundly-email-sign-btn');221 emailAuthBtn.attr('disabled', true);222 $('.auth-form__loader').css('display', 'block');223 $.ajax({224 type: 'POST',225 url: crowdfundlyAuth.ajax_url,226 data: {227 action: "crowdfundly_email_login_auth",228 emailLoginData: formData,229 security: crowdfundlyAuth.nonce,230 },231 success: function (response) {232 console.log(response);233 if (response.code == 200) {234 swal({235 title: crowdfundlyAuth.success,236 text: "Log In Successful",237 icon: 'success'238 });239 setDashboard(response);240 setTimeout(() => {241 window.location.reload();242 }, 1500);243 }244 $('.auth-form__loader').css('display', 'none');245 },246 error: function(error) {247 console.log(error);248 swal({249 title: crowdfundlyAuth.warning,250 text: crowdfundlyAuth.email_not_found,251 icon: 'warning'252 });253 $('.auth-form__loader').css('display', 'none');254 emailAuthBtn.removeAttr('disabled');255 }256 });257 }258 function emailLogInAuth() {259 const emailAuth = $('#email-auth-form');260 emailAuth.on('submit', function(e) {261 e.preventDefault();262 emailSubmitAuth();263 });264 }265 function authTypeView() {266 const keyAuthBtn = $('#app-key-auth-btn');267 const appKeyMarkup = $('#app-key-auth');268 const emailAuthMarkup = $('#email-auth');269 const forgetPassword = $('#crowdfundl-forget-password-form-wrapper');270 keyAuthBtn.on('click', function() {271 $(this).toggleClass('email-auth');272 $(this).text($(this).data('email-text'));273 appKeyMarkup.css('display', 'block');274 emailAuthMarkup.css('display', 'none');275 forgetPassword.css('display', 'none');276 if ( $(this).hasClass('email-auth') ) {277 $(this).text($(this).data('key-text'));278 appKeyMarkup.css('display', 'none');279 emailAuthMarkup.css('display', 'block');280 }281 });282 }283 function forgetPassword() {284 const forgetPasswordElement = $('#forget-password-btn');285 const forgetPasswordBtn = $('#crowdfundly-forget-password-btn');286 const forgetPasswordWrap = $('#crowdfundl-forget-password-form-wrapper');287 const emailAuth = $('#email-auth');288 if (forgetPasswordElement) {289 forgetPasswordElement.on('click', function() {290 console.log("Forget Password...");291 emailAuth.css('display', 'none');292 forgetPasswordWrap.css('display', 'block');293 });294 }295 if (forgetPasswordBtn) {296 forgetPasswordBtn.on('click', function() {297 const self = $(this);298 self.attr('disabled', true);299 $('#forgetpassword-loader').css('display', 'block');300 const emailAddress = $('#forgetPasswordEmail').val();301 const url = $(this).data('api-base') + '/api/v1/auth/password/email';302 $.ajax({303 type: "POST",304 url: url,305 data: {email: emailAddress},306 success: function(res) {307 $('.forget-password-msg').html(res.message);308 self.attr('disabled', false);309 $('#forgetpassword-loader').css('display', 'none');310 },311 error: function(err) {312 $('.forget-password-msg').addClass('error');313 $('.forget-password-msg').html(self.data('error-msg'));314 self.attr('disabled', false);315 $('#forgetpassword-loader').css('display', 'none');316 }317 });318 });319 }320 }321 function connect_api() {322 let ApiKeyInput = $("#crowdfundly_api_key");323 let ConnectApiKeyButton = $("#connect_api");324 if (!ApiKeyInput || !ConnectApiKeyButton) {325 return;326 }327 ConnectApiKeyButton.on( "click", function(e) {328 const self = $(this);329 self.attr('disabled', true);330 if (! ApiKeyInput.val() ) {331 swal({332 title: crowdfundlyAuth.warning,333 text: crowdfundlyAuth.api_not_provided,334 icon: 'warning'335 });336 return;337 }338 ConnectApiKeyButton.children("span").text(crowdfundlyAuth.connecting);339 $('.auth-form__loader').show();340 $.ajax({341 type: 'POST',342 url: crowdfundlyAuth.ajax_url,343 data: {344 action: "crowdfundly_connect_api",345 crowdfundly_connect_apikey: ApiKeyInput.val(),346 security: crowdfundlyAuth.nonce,347 },348 success: function (response) {349 console.log(response);350 if ( response.code == 200 ) {351 swal({352 title: crowdfundlyAuth.success,353 text: crowdfundlyAuth.success_authenticated,354 icon: 'success'355 });356 setDashboard(response);357 window.location.reload();358 } else {359 swal({360 title: crowdfundlyAuth.failed,361 text: crowdfundlyAuth.failed_authentication,362 icon: 'error'363 }).then((result) => {364 ApiKeyInput.val('');365 });366 }367 ConnectApiKeyButton.children("span").text(crowdfundlyAuth.connect);368 $('.auth-form__loader').hide();369 self.removeAttr('disabled');370 },371 error: function(error) { 372 // console.log(error);373 swal({374 title: crowdfundlyAuth.failed,375 text: crowdfundlyAuth.failed_authentication,376 icon: 'error'377 }).then((result) => {378 ApiKeyInput.val('');379 });380 ConnectApiKeyButton.children("span").text(crowdfundlyAuth.connect);381 $('.auth-form__loader').hide();382 self.removeAttr('disabled');383 }384 })385 });386 }387 function disconnect_api() {388 let button = $(this);389 let disconnectApiElem = $(".crowdfundly-footer-link-general");390 disconnectApiElem.click(function (e) {391 $.ajax({392 type: "POST",393 url: crowdfundlyAuth.ajax_url,394 data: {395 action: 'crowdfundly_disconnect_api',396 security: crowdfundlyAuth.nonce,397 },398 beforeSend: function () {399 $(this).html('<span>'+crowdfundlyAuth.disconnecting+'</span>');400 },401 success: function (res) {402 swal({403 title: crowdfundlyAuth.success,404 text: crowdfundlyAuth.success_disconnected,405 icon: 'success'406 });407 localStorage.removeItem('auth._token.local');408 localStorage.removeItem('crowdfundly');409 Cookies.remove('auth._token.local');410 411 window.location.reload();412 }413 })414 });415 }416 // set data when authenticating417 async function setDashboard(response) {418 await Cookies.set('auth._token.local', 'Bearer ' + response.token);419 await localStorage.setItem('auth._token.local', 'Bearer ' + response.token);420 var crowdfundly = JSON.parse(await localStorage.getItem('crowdfundly'));421 if ( !crowdfundly ) {422 crowdfundly = {423 auth: {424 busy: false,425 loggedIn: true,426 redirect: '/dashboard',427 strategy: 'local'428 }429 }430 }431 crowdfundly.auth.busy = false;432 crowdfundly.auth.loggedIn = true;433 crowdfundly.auth.redirect = "/dashboard";434 crowdfundly.auth.strategy = "local";435 // crowdfundly.organization = (response.user.length != 0) ? response.user : null;436 crowdfundly.organization = (response.email_login == 1 && response.user) ? response.user : null;437 if ( response.email_login == 0 ) {438 crowdfundly.organization = response.organization ? response.organization : null;439 }440 crowdfundly.countries = response.countries;441 crowdfundly.currencies = response.currencies;442 crowdfundly.logout_api_url = crowdfundlyAuth.logout_api_url;443 crowdfundly.changed_organization = crowdfundlyAuth.changed_organization;444 crowdfundly.logout_redirect_url = crowdfundlyAuth.plugin_url;445 crowdfundly.email_login = response.email_login;446 crowdfundly.site_url = response.site_url;447 crowdfundly.organization_url = response.organization_url;448 crowdfundly.campaign_url = response.campaign_url;449 crowdfundly.site_url = crowdfundlyAuth.site_url;450 crowdfundly.organization_url = crowdfundlyAuth.organization_url;451 crowdfundly.campaign_url = crowdfundlyAuth.campaign_url;452 await localStorage.setItem('crowdfundly', JSON.stringify(crowdfundly));453 }454 // login redirection455 function pre_set_dashboard() {456 const token = localStorage.getItem('auth._token.local');457 if ( !token && (crowdfundlyAuth.is_dashboard_page || crowdfundlyAuth.is_setting_page) ) {458 459 Cookies.set('auth._token.local', 'Bearer ' + crowdfundlyAuth.bearer_token);460 localStorage.setItem('auth._token.local', 'Bearer ' + crowdfundlyAuth.bearer_token)461 var crowdfundly = JSON.parse(localStorage.getItem('crowdfundly'));462 if (!crowdfundly) {463 crowdfundly = {464 auth: {465 busy: false,466 loggedIn: true,467 redirect: '/dashboard',468 strategy: 'local'469 }470 }471 }472 crowdfundly.auth.busy = false473 crowdfundly.auth.loggedIn = true474 crowdfundly.auth.redirect = "/dashboard"475 crowdfundly.auth.strategy = "local"476 // crowdfundly.organization = (crowdfundlyAuth.user.length != 0) ? crowdfundlyAuth.user : null;477 crowdfundly.organization = (crowdfundlyAuth.email_login == 1 && crowdfundlyAuth.user.organizations) ? crowdfundlyAuth.user.organizations[0] : null;478 if ( crowdfundlyAuth.email_login == false ) {479 crowdfundly.organization = crowdfundlyAuth.user ? crowdfundlyAuth.user : null;480 }481 crowdfundly.countries = crowdfundlyAuth.countries;482 crowdfundly.currencies = crowdfundlyAuth.currencies;483 crowdfundly.logout_api_url = crowdfundlyAuth.logout_api_url;484 crowdfundly.changed_organization = crowdfundlyAuth.changed_organization;485 crowdfundly.logout_redirect_url = crowdfundlyAuth.plugin_url;486 crowdfundly.email_login = crowdfundlyAuth.email_login;487 crowdfundly.site_url = crowdfundlyAuth.site_url;488 crowdfundly.organization_url = crowdfundlyAuth.organization_url;489 crowdfundly.campaign_url = crowdfundlyAuth.campaign_url;490 localStorage.setItem('crowdfundly', JSON.stringify(crowdfundly));491 window.location.href = crowdfundlyAuth.plugin_url;492 }493 }...
list.js
Source:list.js
1const express = require('express');2const router = express.Router();3// è·åç¨æ·å表4router.get('/menuList', (req, res) => {5 res.send({6 list: [{7 id: 100,8 authName: 'ç¨æ·ç®¡ç',9 path: 'users',10 order: 1,11 children: [{12 id: 110,13 authName: 'ç¨æ·å表',14 path: 'users',15 order: 216 }]17 }, {18 id: 200,19 authName: 'æé管ç',20 path: 'rights',21 order: 2,22 children: [{23 id: 210,24 authName: 'æéå表',25 path: 'rights_user',26 order: 227 }, {28 id: 220,29 authName: 'è·¯å¾å表',30 path: 'rights',31 order: 332 }]33 }, {34 id: 300,35 authName: 'åå管ç',36 path: 'goods',37 order: 1,38 children: [{39 id: 310,40 authName: 'ååå表',41 path: 'goods_list',42 order: 243 },{44 id: 330,45 authName: 'åååç±»',46 path: 'goods',47 order: 248 }]49 }],50 meta: {51 message: 'è·åå表',52 state: 20053 },54 powerList: [{55 id: 100,56 roleName: 'è¶
级管çå',57 roleDesc: 'æé«æ§è¡è
',58 children: [{59 id: 101,60 authName: 'åå管ç',61 path: null,62 children: [{63 id: 102,64 authName: 'ååå表',65 path: null,66 children: [{67 id: 103,68 authName: 'æ·»å åå',69 path: null70 }, {71 id: 104,72 authName: 'ååä¿®æ¹',73 path: null74 }, {75 id: 105,76 authName: 'ååå é¤',77 path: null78 }, {79 id: 106,80 authName: 'æ´æ°ååå¾ç',81 path: null82 }, {83 id: 107,84 authName: 'æ´æ°ååå±æ§',85 path: null86 }, {87 id: 108,88 authName: 'æ´æ°ååç¶æ',89 path: null90 }, {91 id: 109,92 authName: 'è·åååä¿¡æ¯',93 path: null94 }]95 }, {96 id: 110,97 authName: 'åç±»åæ°',98 path: null,99 children: [{100 id: 111,101 authName: 'è·ååæ°å表',102 path: null103 }, {104 id: 112,105 authName: 'å建åååæ°',106 path: null107 }, {108 id: 113,109 authName: 'å é¤åååæ°',110 path: null111 }]112 }, {113 id: 114,114 authName: 'åååç±»',115 path: null,116 children: [{117 id: 115,118 authName: 'æ·»å åç±»',119 path: null120 }, {121 id: 116,122 authName: 'å é¤åç±»',123 path: null124 }, {125 id: 117,126 authName: 'è·åå类详æ
',127 path: null128 }]129 }]130 }, {131 id: 118,132 authName: '订å管ç',133 path: null,134 children: [{135 id: 119,136 authName: '订åå表',137 path: null,138 children: [{139 id: 120,140 authName: 'æ·»å 订å',141 path: null142 }, {143 id: 121,144 authName: '订åæ´æ°',145 path: null146 }, {147 id: 122,148 authName: 'è·å订å详æ
',149 path: null150 }]151 }]152 }, {153 id: 123,154 authName: 'æé管ç',155 path: null,156 children: [{157 id: 124,158 authName: 'è§è²å表',159 path: null,160 children: [{161 id: 125,162 authName: 'æ·»å è§è²',163 path: null164 }, {165 id: 126,166 authName: 'å é¤è§è²',167 path: null168 }, {169 id: 127,170 authName: 'è§è²ææ',171 path: null172 }, {173 id: 128,174 authName: 'åæ¶è§è²ææ',175 path: null176 }, {177 id: 129,178 authName: 'è·åè§è²å表',179 path: null180 }, {181 id: 130,182 authName: 'è·åè§è²è¯¦æ
',183 path: null184 }, {185 id: 131,186 authName: 'æ´æ°è§è²ä¿¡æ¯',187 path: null188 }, {189 id: 132,190 authName: 'æ´æ°è§è²æé',191 path: null192 }]193 }, {194 id: 133,195 authName: 'æéå表',196 path: null,197 children: [{198 id: 134,199 authName: 'æ¥çæé',200 path: null201 }]202 }]203 }, {204 id: 135,205 authName: 'ç¨æ·ç®¡ç',206 path: null,207 children: [{208 id: 136,209 authName: 'ç¨æ·å表',210 path: null,211 children: [{212 id: 137,213 authName: 'æ·»å ç¨æ·',214 path: null215 }, {216 id: 138,217 authName: 'å é¤ç¨æ·',218 path: null219 }, {220 id: 139,221 authName: 'æ´æ°ç¨æ·',222 path: null223 }, {224 id: 140,225 authName: 'è·åç¨æ·è¯¦æ
',226 path: null227 }, {228 id: 141,229 authName: 'åé
ç¨æ·è§è²',230 path: null231 }, {232 id: 142,233 authName: '设置管çç¶æ',234 path: null235 }]236 }]237 }, {238 id: 143,239 authName: 'æ°æ®ç»è®¡',240 path: null,241 children: [{242 id: 144,243 authName: 'æ°æ®æ¥è¡¨',244 path: null,245 children: [{246 id: 145,247 authName: 'æ¥çæ°æ®',248 path: null249 }]250 }]251 }]252 }, {253 id: 146,254 roleName: '管çå',255 roleDesc: 'ç¹ææ§è¡è
',256 children: [{257 id: 147,258 authName: 'åå管ç',259 path: null,260 children: [{261 id: 148,262 authName: 'ååå表',263 path: null,264 children: [{265 id: 149,266 authName: 'æ·»å åå',267 path: null268 }, {269 id: 150,270 authName: 'ååä¿®æ¹',271 path: null272 }, {273 id: 151,274 authName: 'ååå é¤',275 path: null276 }]277 }, {278 id: 152,279 authName: 'åç±»åæ°',280 path: null,281 children: [{282 id: 153,283 authName: 'è·ååæ°å表',284 path: null285 }, {286 id: 154,287 authName: 'å建åååæ°',288 path: null289 }]290 }, {291 id: 155,292 authName: 'åååç±»',293 path: null,294 children: [{295 id: 156,296 authName: 'æ·»å åç±»',297 path: null298 }]299 }]300 }, {301 id: 157,302 authName: '订å管ç',303 path: null,304 children: [{305 id: 158,306 authName: '订åå表',307 path: null,308 children: [{309 id: 159,310 authName: 'æ·»å 订å',311 path: null312 },{313 id: 160,314 authName: 'è·å订å详æ
',315 path: null316 }]317 }]318 }, {319 id: 161,320 authName: 'æé管ç',321 path: null,322 children: [{323 id: 162,324 authName: 'è§è²å表',325 path: null,326 children: [{327 id: 163,328 authName: 'æ·»å è§è²',329 path: null330 }, {331 id: 164,332 authName: 'è·åè§è²å表',333 path: null334 }, {335 id: 165,336 authName: 'è·åè§è²è¯¦æ
',337 path: null338 }]339 }, {340 id: 166,341 authName: 'æéå表',342 path: null,343 children: [{344 id: 167,345 authName: 'æ¥çæé',346 path: null347 }]348 }]349 }, {350 id: 168,351 authName: 'ç¨æ·ç®¡ç',352 path: null,353 children: [{354 id: 169,355 authName: 'ç¨æ·å表',356 path: null,357 children: [{358 id: 170,359 authName: 'æ·»å ç¨æ·',360 path: 171361 }, {362 id: 172,363 authName: 'è·åç¨æ·è¯¦æ
',364 path: null365 }, {366 id: 173,367 authName: 'åé
ç¨æ·è§è²',368 path: null369 }]370 }]371 }, {372 id: 174,373 authName: 'æ°æ®ç»è®¡',374 path: null,375 children: [{376 id: 175,377 authName: 'æ°æ®æ¥è¡¨',378 path: null,379 children: [{380 id: 176,381 authName: 'æ¥çæ°æ®',382 path: null383 }]384 }]385 }]386 }, {387 id: 177,388 roleName: 'ç¹æç¨æ·',389 roleDesc: 'æ¥æç¹æçç¨æ·',390 children: [{391 id: 178,392 authName: 'åå管ç',393 path: null,394 children: [{395 id: 179,396 authName: 'ååå表',397 path: null,398 children: [{399 id: 180,400 authName: 'æ·»å åå',401 path: null402 }]403 }]404 }, {405 id: 181,406 authName: '订å管ç',407 path: null,408 children: [{409 id: 182,410 authName: '订åå表',411 path: null,412 children: [{413 id: 183,414 authName: 'æ·»å 订å',415 path: null416 }, {417 id: 184,418 authName: 'è·å订å详æ
',419 path: null420 }]421 }]422 }, {423 id: 185,424 authName: 'æ°æ®ç»è®¡',425 path: null,426 children: [{427 id: 186,428 authName: 'æ°æ®æ¥è¡¨',429 path: null,430 children: [{431 id: 187,432 authName: 'æ¥çæ°æ®',433 path: null434 }]435 }]436 }]437 }, {438 id: 188,439 roleName: 'æ®éç¨æ·',440 roleDesc: '大é¨å人çæé',441 children: [{442 id: 189,443 authName: 'æ°æ®ç»è®¡',444 path: null,445 children: [{446 id: 190,447 authName: 'æ°æ®æ¥è¡¨',448 path: null,449 children: [{450 id: 191,451 authName: 'æ¥çæ°æ®',452 path: null453 }]454 }]455 }]456 }]457 });458})...
test_pape.py
Source:test_pape.py
1from openid.extensions import pape2from openid.message import *3from openid.server import server4import unittest5class PapeRequestTestCase(unittest.TestCase):6 def setUp(self):7 self.req = pape.Request()8 def test_construct(self):9 self.failUnlessEqual([], self.req.preferred_auth_policies)10 self.failUnlessEqual(None, self.req.max_auth_age)11 self.failUnlessEqual('pape', self.req.ns_alias)12 req2 = pape.Request([pape.AUTH_MULTI_FACTOR], 1000)13 self.failUnlessEqual([pape.AUTH_MULTI_FACTOR], req2.preferred_auth_policies)14 self.failUnlessEqual(1000, req2.max_auth_age)15 def test_add_policy_uri(self):16 self.failUnlessEqual([], self.req.preferred_auth_policies)17 self.req.addPolicyURI(pape.AUTH_MULTI_FACTOR)18 self.failUnlessEqual([pape.AUTH_MULTI_FACTOR], self.req.preferred_auth_policies)19 self.req.addPolicyURI(pape.AUTH_MULTI_FACTOR)20 self.failUnlessEqual([pape.AUTH_MULTI_FACTOR], self.req.preferred_auth_policies)21 self.req.addPolicyURI(pape.AUTH_PHISHING_RESISTANT)22 self.failUnlessEqual([pape.AUTH_MULTI_FACTOR, pape.AUTH_PHISHING_RESISTANT],23 self.req.preferred_auth_policies)24 self.req.addPolicyURI(pape.AUTH_MULTI_FACTOR)25 self.failUnlessEqual([pape.AUTH_MULTI_FACTOR, pape.AUTH_PHISHING_RESISTANT],26 self.req.preferred_auth_policies)27 def test_getExtensionArgs(self):28 self.failUnlessEqual({'preferred_auth_policies': ''}, self.req.getExtensionArgs())29 self.req.addPolicyURI('http://uri')30 self.failUnlessEqual({'preferred_auth_policies': 'http://uri'}, self.req.getExtensionArgs())31 self.req.addPolicyURI('http://zig')32 self.failUnlessEqual({'preferred_auth_policies': 'http://uri http://zig'}, self.req.getExtensionArgs())33 self.req.max_auth_age = 78934 self.failUnlessEqual({'preferred_auth_policies': 'http://uri http://zig', 'max_auth_age': '789'}, self.req.getExtensionArgs())35 def test_parseExtensionArgs(self):36 args = {'preferred_auth_policies': 'http://foo http://bar',37 'max_auth_age': '9'}38 self.req.parseExtensionArgs(args)39 self.failUnlessEqual(9, self.req.max_auth_age)40 self.failUnlessEqual(['http://foo','http://bar'], self.req.preferred_auth_policies)41 def test_parseExtensionArgs_empty(self):42 self.req.parseExtensionArgs({})43 self.failUnlessEqual(None, self.req.max_auth_age)44 self.failUnlessEqual([], self.req.preferred_auth_policies)45 def test_fromOpenIDRequest(self):46 openid_req_msg = Message.fromOpenIDArgs({47 'mode': 'checkid_setup',48 'ns': OPENID2_NS,49 'ns.pape': pape.ns_uri,50 'pape.preferred_auth_policies': ' '.join([pape.AUTH_MULTI_FACTOR, pape.AUTH_PHISHING_RESISTANT]),51 'pape.max_auth_age': '5476'52 })53 oid_req = server.OpenIDRequest()54 oid_req.message = openid_req_msg55 req = pape.Request.fromOpenIDRequest(oid_req)56 self.failUnlessEqual([pape.AUTH_MULTI_FACTOR, pape.AUTH_PHISHING_RESISTANT], req.preferred_auth_policies)57 self.failUnlessEqual(5476, req.max_auth_age)58 def test_fromOpenIDRequest_no_pape(self):59 message = Message()60 openid_req = server.OpenIDRequest()61 openid_req.message = message62 pape_req = pape.Request.fromOpenIDRequest(openid_req)63 assert(pape_req is None)64 def test_preferred_types(self):65 self.req.addPolicyURI(pape.AUTH_PHISHING_RESISTANT)66 self.req.addPolicyURI(pape.AUTH_MULTI_FACTOR)67 pt = self.req.preferredTypes([pape.AUTH_MULTI_FACTOR,68 pape.AUTH_MULTI_FACTOR_PHYSICAL])69 self.failUnlessEqual([pape.AUTH_MULTI_FACTOR], pt)70class DummySuccessResponse:71 def __init__(self, message, signed_stuff):72 self.message = message73 self.signed_stuff = signed_stuff74 def getSignedNS(self, ns_uri):75 return self.signed_stuff76class PapeResponseTestCase(unittest.TestCase):77 def setUp(self):78 self.req = pape.Response()79 def test_construct(self):80 self.failUnlessEqual([], self.req.auth_policies)81 self.failUnlessEqual(None, self.req.auth_age)82 self.failUnlessEqual('pape', self.req.ns_alias)83 self.failUnlessEqual(None, self.req.nist_auth_level)84 req2 = pape.Response([pape.AUTH_MULTI_FACTOR], 1000, 3)85 self.failUnlessEqual([pape.AUTH_MULTI_FACTOR], req2.auth_policies)86 self.failUnlessEqual(1000, req2.auth_age)87 self.failUnlessEqual(3, req2.nist_auth_level)88 def test_add_policy_uri(self):89 self.failUnlessEqual([], self.req.auth_policies)90 self.req.addPolicyURI(pape.AUTH_MULTI_FACTOR)91 self.failUnlessEqual([pape.AUTH_MULTI_FACTOR], self.req.auth_policies)92 self.req.addPolicyURI(pape.AUTH_MULTI_FACTOR)93 self.failUnlessEqual([pape.AUTH_MULTI_FACTOR], self.req.auth_policies)94 self.req.addPolicyURI(pape.AUTH_PHISHING_RESISTANT)95 self.failUnlessEqual([pape.AUTH_MULTI_FACTOR, pape.AUTH_PHISHING_RESISTANT], self.req.auth_policies)96 self.req.addPolicyURI(pape.AUTH_MULTI_FACTOR)97 self.failUnlessEqual([pape.AUTH_MULTI_FACTOR, pape.AUTH_PHISHING_RESISTANT], self.req.auth_policies)98 def test_getExtensionArgs(self):99 self.failUnlessEqual({'auth_policies': ''}, self.req.getExtensionArgs())100 self.req.addPolicyURI('http://uri')101 self.failUnlessEqual({'auth_policies': 'http://uri'}, self.req.getExtensionArgs())102 self.req.addPolicyURI('http://zig')103 self.failUnlessEqual({'auth_policies': 'http://uri http://zig'}, self.req.getExtensionArgs())104 self.req.auth_age = 789105 self.failUnlessEqual({'auth_policies': 'http://uri http://zig', 'auth_age': '789'}, self.req.getExtensionArgs())106 self.req.nist_auth_level = 3107 self.failUnlessEqual({'auth_policies': 'http://uri http://zig', 'auth_age': '789', 'nist_auth_level': '3'}, self.req.getExtensionArgs())108 def test_getExtensionArgs_error_auth_age(self):109 self.req.auth_age = "older than the sun"110 self.failUnlessRaises(ValueError, self.req.getExtensionArgs)111 self.req.auth_age = -10112 self.failUnlessRaises(ValueError, self.req.getExtensionArgs)113 def test_getExtensionArgs_error_nist_auth_level(self):114 self.req.nist_auth_level = "high as a kite"115 self.failUnlessRaises(ValueError, self.req.getExtensionArgs)116 self.req.nist_auth_level = 5117 self.failUnlessRaises(ValueError, self.req.getExtensionArgs)118 self.req.nist_auth_level = -1119 self.failUnlessRaises(ValueError, self.req.getExtensionArgs)120 def test_parseExtensionArgs(self):121 args = {'auth_policies': 'http://foo http://bar',122 'auth_age': '9'}123 self.req.parseExtensionArgs(args)124 self.failUnlessEqual(9, self.req.auth_age)125 self.failUnlessEqual(['http://foo','http://bar'], self.req.auth_policies)126 def test_parseExtensionArgs_empty(self):127 self.req.parseExtensionArgs({})128 self.failUnlessEqual(None, self.req.auth_age)129 self.failUnlessEqual([], self.req.auth_policies)130 131 def test_parseExtensionArgs_strict_bogus1(self):132 args = {'auth_policies': 'http://foo http://bar',133 'auth_age': 'not too old'}134 self.failUnlessRaises(ValueError, self.req.parseExtensionArgs,135 args, True)136 def test_parseExtensionArgs_strict_bogus2(self):137 args = {'auth_policies': 'http://foo http://bar',138 'auth_age': '63',139 'nist_auth_level': 'some'}140 self.failUnlessRaises(ValueError, self.req.parseExtensionArgs,141 args, True)142 143 def test_parseExtensionArgs_strict_good(self):144 args = {'auth_policies': 'http://foo http://bar',145 'auth_age': '0',146 'nist_auth_level': '0'}147 self.req.parseExtensionArgs(args, True)148 self.failUnlessEqual(['http://foo','http://bar'], self.req.auth_policies)149 self.failUnlessEqual(0, self.req.auth_age)150 self.failUnlessEqual(0, self.req.nist_auth_level)151 def test_parseExtensionArgs_nostrict_bogus(self):152 args = {'auth_policies': 'http://foo http://bar',153 'auth_age': 'old',154 'nist_auth_level': 'some'}155 self.req.parseExtensionArgs(args)156 self.failUnlessEqual(['http://foo','http://bar'], self.req.auth_policies)157 self.failUnlessEqual(None, self.req.auth_age)158 self.failUnlessEqual(None, self.req.nist_auth_level)159 def test_fromSuccessResponse(self):160 openid_req_msg = Message.fromOpenIDArgs({161 'mode': 'id_res',162 'ns': OPENID2_NS,163 'ns.pape': pape.ns_uri,164 'pape.auth_policies': ' '.join([pape.AUTH_MULTI_FACTOR, pape.AUTH_PHISHING_RESISTANT]),165 'pape.auth_age': '5476'166 })167 signed_stuff = {168 'auth_policies': ' '.join([pape.AUTH_MULTI_FACTOR, pape.AUTH_PHISHING_RESISTANT]),169 'auth_age': '5476'170 }171 oid_req = DummySuccessResponse(openid_req_msg, signed_stuff)172 req = pape.Response.fromSuccessResponse(oid_req)173 self.failUnlessEqual([pape.AUTH_MULTI_FACTOR, pape.AUTH_PHISHING_RESISTANT], req.auth_policies)...
authFilter.js
Source:authFilter.js
1import { USER_AUTH,SYS_BUTTON_AUTH } from "@/store/mutation-types"2export function disabledAuthFilter(code,formData) {3 if(nodeDisabledAuth(code,formData)){4 return true;5 }else{6 return globalDisabledAuth(code);7 }8}9function nodeDisabledAuth(code,formData){10 console.log("页é¢æéç¦ç¨--NODE--å¼å§");11 let permissionList = [];12 try {13 console.log("页é¢æéç¦ç¨--NODE--å¼å§",formData);14 if (formData) {15 let bpmList = formData.permissionList;16 permissionList = bpmList.filter(item=>item.type=='2')17 // for (let bpm of bpmList) {18 // if(bpm.type == '2') {19 // permissionList.push(bpm);20 // }21 // }22 }else{23 return false;24 }25 } catch (e) {26 //console.log("页é¢æéå¼å¸¸----", e);27 }28 if (permissionList.length == 0) {29 return false;30 }31 console.log("æµç¨èç¹é¡µé¢æéç¦ç¨--NODE--å¼å§");32 let permissions = [];33 for (let item of permissionList) {34 if(item.type == '2') {35 permissions.push(item.action);36 }37 }38 //console.log("页é¢æé----"+code);39 if (!permissions.includes(code)) {40 return false;41 }else{42 for (let item2 of permissionList) {43 if(code === item2.action){44 console.log("æµç¨èç¹é¡µé¢æéç¦ç¨--NODE--çæ");45 return true;46 }47 }48 }49 return false;50}51function globalDisabledAuth(code){52 console.log("å
¨å±é¡µé¢ç¦ç¨æé--Global--å¼å§");53 let permissionList = [];54 let allPermissionList = [];55 //let authList = Vue.ls.get(USER_AUTH);56 let authList = JSON.parse(sessionStorage.getItem(USER_AUTH) || "[]");57 for (let auth of authList) {58 if(auth.type == '2') {59 permissionList.push(auth);60 }61 }62 //console.log("页é¢ç¦ç¨æé--Global--",sessionStorage.getItem(SYS_BUTTON_AUTH));63 let allAuthList = JSON.parse(sessionStorage.getItem(SYS_BUTTON_AUTH) || "[]");64 for (let gauth of allAuthList) {65 if(gauth.type == '2') {66 allPermissionList.push(gauth);67 }68 }69 //设置å
¨å±é
ç½®æ¯å¦æå½ä¸70 let gFlag = false;//ç¦ç¨å½ä¸71 let invalidFlag = false;//æ æå½ä¸72 if(allPermissionList != null && allPermissionList != "" && allPermissionList != undefined && allPermissionList.length > 0){73 for (let itemG of allPermissionList) {74 if(code === itemG.action){75 if(itemG.status == '0'){76 invalidFlag = true;77 break;78 }else{79 gFlag = true;80 break;81 }82 }83 }84 }85 if(invalidFlag){86 return false;87 }88 if (permissionList === null || permissionList === "" || permissionList === undefined||permissionList.length<=0) {89 return gFlag;90 }91 let permissions = [];92 for (let item of permissionList) {93 if(item.type == '2') {94 permissions.push(item.action);95 }96 }97 //console.log("页é¢ç¦ç¨æé----"+code);98 if (!permissions.includes(code)) {99 return gFlag;100 }else{101 for (let item2 of permissionList) {102 if(code === item2.action){103 console.log("å
¨å±é¡µé¢æé解é¤ç¦ç¨--Global--çæ");104 gFlag = false;105 }106 }107 return gFlag;108 }109}110export function colAuthFilter(columns,pre) {111 let authList = getNoAuthCols(pre);112 const cols = columns.filter(item => {113 if (hasColoum(item,authList)) {114 return true115 }116 return false117 })118 return cols119}120/**121 * ãå表è¡ç¼è¾ãå®ç°ä¸¤ä¸ªåè½ï¼122 * 1ãéèJEditableTableæ æéçå段123 * 2ãç¦ç¨JEditableTableæ æéçå段124 * @param columns125 * @param pre126 * @returns {*}127 */128export function colAuthFilterJEditableTable(columns,pre) {129 let authList = getAllShowAndDisabledAuthCols(pre);130 const cols = columns.filter(item => {131 let oneAuth = authList.find(auth => {132 return auth.action === pre + item.key;133 });134 if(!oneAuth){135 return true136 }137 //代ç 严谨å¤çï¼é²æ¢ä¸ä¸ªæææ è¯ï¼é
ç½®å¤æ¬¡138 if(oneAuth instanceof Array){139 oneAuth = oneAuth[0]140 }141 //ç¦ç¨é»è¾142 if (oneAuth.type == '2' && !oneAuth.isAuth) {143 item["disabled"] = true144 return true145 }146 //éèé»è¾é»è¾147 if (oneAuth.type == '1' && !oneAuth.isAuth) {148 return false149 }150 return true151 })152 return cols153}154function hasColoum(item,authList){155 if (authList.includes(item.dataIndex)) {156 return false157 }158 return true159}160//æéæ ææ¶ä¸åæ§å¶ï¼æææ¶æ§å¶ï¼åªè½æ§å¶ æ¾ç¤ºä¸æ¾ç¤º161//æ ¹æ®ææç åç¼è·åæªææçåä¿¡æ¯162export function getNoAuthCols(pre){163 if(!pre || pre.length==0){164 return []165 }166 let permissionList = [];167 let allPermissionList = [];168 //let authList = Vue.ls.get(USER_AUTH);169 let authList = JSON.parse(sessionStorage.getItem(USER_AUTH) || "[]");170 for (let auth of authList) {171 //æ¾ç¤ºçç¥ï¼ææç¶æ172 if(auth.type == '1'&&startWith(auth.action,pre)) {173 permissionList.push(substrPre(auth.action,pre));174 }175 }176 //console.log("页é¢ç¦ç¨æé--Global--",sessionStorage.getItem(SYS_BUTTON_AUTH));177 let allAuthList = JSON.parse(sessionStorage.getItem(SYS_BUTTON_AUTH) || "[]");178 for (let gauth of allAuthList) {179 //æ¾ç¤ºçç¥ï¼ææç¶æ180 if(gauth.type == '1'&&gauth.status == '1'&&startWith(gauth.action,pre)) {181 allPermissionList.push(substrPre(gauth.action,pre));182 }183 }184 const cols = allPermissionList.filter(item => {185 if (permissionList.includes(item)) {186 return false;187 }188 return true;189 })190 return cols;191}192/**193 * é¢å¤å¢å æ¹æ³ãç¨äºè¡ç¼è¾ç»ä»¶ã194 * date: 2020-04-05195 * author: scott196 * @param pre197 * @returns {*[]}198 */199function getAllShowAndDisabledAuthCols(pre){200 //ç¨æ·æ¥æçæé201 let userAuthList = JSON.parse(sessionStorage.getItem(USER_AUTH) || "[]");202 //å
¨é¨æéé
ç½®203 let allAuthList = JSON.parse(sessionStorage.getItem(SYS_BUTTON_AUTH) || "[]");204 let newAllAuthList = allAuthList.map(function (item, index) {205 let hasAuthArray = userAuthList.filter(u => u.action===item.action );206 if (hasAuthArray && hasAuthArray.length>0) {207 item["isAuth"] = true208 }209 return item;210 })211 return newAllAuthList;212}213function startWith(str,pre) {214 if (pre == null || pre == "" || str==null|| str==""|| str.length == 0 || pre.length > str.length)215 return false;216 if (str.substr(0, pre.length) == pre)217 return true;218 else219 return false;220}221function substrPre(str,pre) {222 return str.substr(pre.length);...
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!!