This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Create api key | |
module.exports.createApiKey = function(req, res) { | |
req.user.createApiKey(function(err, apiKey){ | |
if(err) return helpers.handleError(err,res); | |
return res.status(201).send({status: 'success', code: 'api_key_created', message: 'Api key created.', data: apiKey}); | |
}); | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//Sign out -> delete all access and refresh tokens | |
module.exports.signOut = function(req, res){ | |
//Delete refresh tokens | |
req.user.getRefreshTokens(function(err,refreshTokens){ | |
refreshTokens.each(deleteToken, function (err) { | |
if(err) { | |
res.status(400).send({ message: 'Oops! There was an error: ' + err.userMessage}); | |
} else { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const async = require('async'); | |
const parser = require('ua-parser-js'); | |
function checkMultipleLogin(account, req, res) { | |
var sendemail = true; | |
var uagent = req.headers['user-agent']; | |
var ua = parser(uagent); | |
var ip = req.headers['x-forwarded-for'] || | |
req.connection.remoteAddress || | |
req.socket.remoteAddress || |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Init Stormpath for user management and authentication | |
app.use(stormpath.init(app, { | |
//Your other options you might have | |
expand: { | |
//The verification code will be saved to customData, so expand it first | |
customData: true | |
}, | |
postRegistrationHandler: function(account, req, res, next) { | |
//Create a verification code to verify email address later | |
helpers.createVerificationCode(account); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
preLoginHandler: function(formData, req, res, next) { | |
var authRequest = { | |
username: formData.login, | |
password: formData.password | |
}; | |
//Try to authenticate the user | |
req.app.get('stormpathApplication').authenticateAccount(authRequest, function(err, result) { | |
//if (err) return helpers.handleError(err,res); | |
if (err && err.code == 7100) { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//This works with the node.js stormpath sdk | |
const stormpath = require('stormpath'); | |
/* | |
This route will redirect to the Stormpath ID Site | |
*/ | |
module.exports.idSiteRedirect = function(req,res,next) { | |
//Create ID Site Url | |
var url = req.app.get('stormpathApplication').createIdSiteUrl({ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
function get_shipping_methods() { | |
$active_methods = array(); | |
$custom_zones = WC_Shipping_Zones::get_zones(); | |
$worldwide_zone = new WC_Shipping_Zone( 0 ); | |
$worldwide_methods = $worldwide_zone->get_shipping_methods(); | |
foreach ( $custom_zones as $zone ) { | |
$shipping_methods = $zone['shipping_methods']; | |
foreach ($shipping_methods as $shipping_method) { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
if ( ! defined( 'ABSPATH' ) ) { | |
exit; | |
} | |
if ( ! class_exists( 'WC_Sample_Webhook', false ) ) : | |
class WC_Sample_Webhook { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
/* | |
Plugin Name: VP Árlista export | |
Plugin URI: http://visztpeter.me | |
Author: Viszt Péter | |
Version: 1.0 | |
*/ | |
if ( ! defined( 'ABSPATH' ) ) exit; // Exit if accessed directly |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
/* | |
I built custom product pages with a simple add to cart button(using the add_to_cart shortcode) for a webshop. | |
There was no need for category pages, shop pages, cart or anything like that, just a simple product page with an add to cart button that redirects to checkout directly. | |
Here is how you can do this: | |
1. Delete the My Account page | |
2. Delete the Shop page | |
*/ |
OlderNewer