I want to use the SPService GetUserProfile, but I don't have the accountName, the GUID, the Index or the email... I only have a param which is employeeNumber (I guess this is specific to my compagnie).
I check on : http://spservices.codeplex.com/wikipage?title=UserProfileService, but I can't find how to do it.
Is it possible to get a user profile searching with a specific param ?
I can only use HTML/JS, I don't access to the server.
The following code should work for all users who have at least logged into the site collection at some point. (The User Information List doesn't contain everyone from AD.) Sub your own values for SITE, myFieldName, and myFieldValue. SITE has to be the site collection, not a subsite.
<script src="PathToJQuery"></script>
<script src="PathToSPServices2014"></script>
<script>
$(document).ready( function(){
SITE = "http://mysitecollection/";
LIST = "User Information List";
var myFieldName = "ows_JobTitle";
var myFieldValue = "Electrician";
var spPromise1 = $().SPServices({
webURL: SITE,
operation: "GetListItems",
listName: LIST,
async: false
});
spPromise1.done(function(){
$(spPromise1.responseXML).SPFilterNode("z:row").each(function(){
if($(this).attr(myFieldName)==myFieldValue){
console.log($(this).attr("ows_ID") + ": " + $(this).attr("ows_Title")); //Returns user ID and Display Name
}
});
});
});
</script>
Related
How do I handle using select2 with ModelChoiceField, but enable adding a new record
I have the Select2 JS in place, and everything works well. I can use my queryset for the ModelChoiceField, and that works. However, if I try to add a new record all I get is the error "Select a valid choice. That choice is not one of the available choices". Which is true - in the view I tried to grab "ID 0" to then create a new record, but can't get past validation without the above error
Also, if I do get this to work, it will provide the "0" ID, but ultimately I require the "term" for the new record, but can't see how this is done
<script type="text/javascript">
$("#id_indoor_cooler").select2({
theme:"bootstrap4",
search_fields: ['model_number'],
tags: true,
createTag: function (params) {
var term = $.trim(params.term);
if (term === '') {
return null;
}
return {
id: 0,
text: term,
newTag: true, // add additional parameters,
value: "myCustomValue"
}
}
});
</script>
i have my website in ruby on rails 5 and i'm updating my stripe payment gateway with this link but clicking my button doesn't redirect me to the stripe checkout, this is what i have in the controller:
def index
Stripe.api_key = Rails.configuration.stripe[:secret_key]
session = Stripe::Checkout::Session.create(
payment_method_types: ['card'],
line_items: [{
price: 'price_1HKywnBS16ZK5Vr3GYCRvTir',
quantity: 1,
}],
mode: 'subscription',
success_url: 'https://www.my_site.network/success?session_id={CHECKOUT_SESSION_ID}',
cancel_url: 'https://www.my_site.network/cancel',
)
end
I think the error may be when replacing the session id in the javascript code of my index view:
<button id="checkout-button">Pay</button>
<script src="https://js.stripe.com/v3/"></script>
<script type="text/javascript">
var stripe = Stripe('<%= Rails.configuration.stripe[:publishable_key] %>');
var checkoutButton = document.getElementById('checkout-button');
checkoutButton.addEventListener('click', function() {
stripe.redirectToCheckout({
// Make the id field from the Checkout Session creation API response
// available to this file, so you can provide it as argument here
// instead of the {{CHECKOUT_SESSION_ID}} placeholder.
sessionId: '<%=session.id%>'
}).then(function (result) {
// If `redirectToCheckout` fails due to a browser or network
// error, display the localized error message to your customer
// using `result.error.message`.
});
});
</script>
you don't have to use '<%=session.id%>'.
The value that you must to use there is the entire value that you store in session when you do: Stripe::Checkout::Session.create in your controller.
I am using the OffAmazonPayments JS library to allow users to log into their Amazon account, access their address book, and eventually to pay with their Amazon account. The AddressBook widget will let me retrieve general address info, but without the address consent token, I cannot get the street address.
http://docs.developer.amazonservices.com/en_US/off_amazon_payments/OffAmazonPayments_GetOrderReferenceDetails.html
This link indicates that I can retrieve the address consent token from the Button object after authentication, but it's not clear how that works; in the definition of the sign-in Button, there's an "onSignIn" callback which receives an orderReference object, but that object doesn't seem to contain any such token.
Please see the Amazon Payments documentation..specifically this page: https://payments.amazon.com/documentation/lpwa/201953150
As you can see in the following code snippet (taken from said page) you can retrieve the token from the "amazon.Login.authorize(...)" function.
Note: You first must include in the "scope" parameter "payments:shipping_address" as one of your scopes in order to get the "address consent token". Below I'm including other scopes so you can see how to list more than one.
The CAPS words/parameters would be replaced by your own desired parameters.
<script type="text/javascript">
var authRequest;
var addressConsentToken;
OffAmazonPayments.Button("AmazonPayButton", "YOUR_SELLER_ID", {
type: "ENTER_TYPE_PARAMETER",
color: "ENTER_COLOR_PARAMETER",
size: "ENTER_SIZE_PARAMETER",
language: "ENTER_LANGUAGE_PARAMETER",
authorization: function() {
loginOptions = {scope: "profile payments:widget payments:shipping_address",
popup: "ENTER_POPUP_PARAMETER"};
authRequest = amazon.Login.authorize (loginOptions,
function(response) {
addressConsentToken = response.access_token;
});
},
onSignIn: function (orderReference) {
var referenceId = orderReference.getAmazonOrderReferenceId();
if (!referenceId) {
errorHandler(new Error('referenceId missing'));
} else {
window.location = "YOUR_REDIRECT_URL" + '?referenceId=' +
orderReference.getAmazonOrderReferenceId() +
"&access_token=" + addressConsentToken;
}
},
onError:errorHandler || function(error) {
// your error handling code
}
});
</script>
I have a register form in html that has a button that type of submit and the name of registerSubmit like this:
<input class="RegisterButton right green" name="registerSubmit" type="submit" value="Continue">
I want to check the form with Ajax and then if every thing is valid then redirect the user to her/his profile.But when I want to redirect the user to his/her profile I can't send the submit input that its name is registerSubmit. here is a section of JQuery code that related to this event:
$("#mainRegisterForm").submit(function(event){
var thisRegisterForm = $(this);
$(".ajaxLogoRegister").show();
event.preventDefault();
var firstName = $("input[name='firstname']").val();
var lastName = $("input[name='lastname']").val();
var emailAddress = $("input[name='email']").val();
var password = $("input[name='password']").val();
var rePass = $("input[name='rePass']").val();
var sex = "NULL";
if ($("input[name='gender']").is(":checked")){
sex = $("input[name='gender']:checked").val();
}
var data ={
firstname:firstName,
lastname:lastName,
emailaddress:emailAddress,
password:password,
repass:rePass,
sex:sex
};
$.ajax({
url: 'ajax/registercheck',
data: data,
dataType: 'json',
success:function(result){
if(result.fn==0){
//do some stuff
}
//another if conditions that checks the validity of every field of refister form
...
...
$(".ajaxLogoRegister").hide();
if(result.isOK=='1'){ //isOK = 1 when every filed is valid and user must redirect to his/her profile
thisRegisterForm.unbind('submit').submit();
}
}
});
});
My main problem is that when I click the registerSubmit button in views.py the request.POST.get('registerSubmit') returns None object instead of Continue value.
when I don't use Ajax and send the form normally registerSubmit value is Continue and every thing is OK.where I am wrong?
By default, $.ajax(); will issue a GET request, not a POST. You need to specify that in your ajax options. Second, I don't see where you're accessing the value of the element named "registerSubmit". I see an "rePass", but you're not including the value you're expecting to find in the request.
You need to either specifically set the "type" ajax option type to "POST" or retrieve the method property from the form element:
$ajax({
url: 'ajax/registercheck',
data: data,
dataType: 'json',
type: 'POST',
....
});
I am trying to do a facebook login for my firebase app. This is the first time I am using a FB login. I went through the article and small tutorials. But I am stuck at the front end
i.e the button creating part in my index.html and linking it to my firebase variable.
I saw the firefeed example and it is very differently done from the procedure on the FB developers guide. Any help will be great.
As an extension to the login I also want to access the graph data of the user logging in
This is my javascript, What will go in my HTML.
var myDataRef = new Firebase('[myFirebase]');
var authClient = new FirebaseAuthClient(myDataRef);
authClient.login("facebook", function (err, token, info) {
if (!err) {
console.log("Got token " + token + " for user " + info.name);
}
});
Check out http://firebase.github.io/firebase-simple-login/ for an example of Firebase Simple Login in action that you can copy / fork and drop into your application.
Here's a simple example of an application which allows you to login to Facebook upon link click:
Login
<script type="text/javascript" src="https://cdn.firebase.com/v0/firebase.js"></script>
<script type="text/javascript" src="https://cdn.firebase.com/v0/firebase-auth-client.js"></script>
<script type="text/javascript">
var firebaseRef = new Firebase("[myFirebase]");
var authClient = new FirebaseAuthClient(firebaseRef, function(error, user) {
if (error) {
// an error occurred while attempting login
console.log('an error occurred:');
console.log(error);
} else if (user) {
// user authenticated with Firebase
console.log('logged in:');
console.log(user);
} else {
// user is logged out
console.log('logged out');
}
});
</script>
</body>
</html>