Parse Account Display - swift

Hi I'm trying to display the logged in username in a text field. Before I started using parse I would simply say let Account = NSUserDefaults.standardUserDefaults().stringForKey("userName") then say self.textfield.text = "Account: " + Account!).
Now that I'm using Parse and my username is stored in a server I'm not sure how to access the string that would be the username so I can use it in a label
Please help. Thanks

Assuming everything else is set up correctly, you should be able to use PFUser.currentUser().username.

Related

titanium multiple recipients email dialog

im using titanium and need to send an email to multiple recipients. the official docs only show how to send to one individual email address.
can someone please give a more concrete example how the getToRecipients and setToRecipients methods are applied correctly so that an email is sent to multiple recipients?
https://developer.appcelerator.com/question/149943/emaildialog-gettorecipients-does-not-work
i need to pass an array (contacts) to the emailDialog.ToRecipients property:
["email#example.net","email2#example.net"]
the code below does not work with this error message (ive also tried it unsuccessfully without the "[]" in setToRecipients):
Basic functions[2807:70b]
["email#example.net","email2#example.net"]is not a valid email
address.
var emails = JSON.stringify(contacts);
var emailDialog = Ti.UI.createEmailDialog();
emailDialog.setToRecipients([emails]);
emailDialog.subject = "Hello from Titanium";
emailDialog.messageBody = '<b>Appcelerator Titanium Rocks!</b>';
emailDialog.open();
thx for any info on this!
Have you tried this?
emailDialog.setToRecipients(contacts);
The Appcelerator Documentation says that EmailDialog.toRecipients is an String [].
See u!
Why do you pass your contacts through JSON.stringify and then put it inside array with one element?
EmailDialog.setToRecipients method requires array of strings, and every single one string should be proper email address. To make it work change your code into:
var emailDialog = Ti.UI.createEmailDialog();
emailDialog.setToRecipients(contacts);
emailDialog.subject = "Hello from Titanium";
emailDialog.messageBody = "<b>Appcelerator Titanium Rocks!</b>";
emailDialog.open();
I'm assuming that contacts variable contains this array (based on your error message):
var contacts = ["email#example.net","email2#example.net"];

GAS - setTag() - getTag() still not working

I'm creating a webapp which allow :
to log using data stored in a spreadsheet (login and password)
to add some data to this spreadsheet (bet on rubgy matchs)
My problem is to recognize which user is connected.
What i did so far
in the doGet function, where all panels except connection are invisible, I created a label where i'll store the login into the tag
var loginlabel=app.createLabel().setId('loginlabel').setText('test').setVisible(true);
in the connection, I store the login into a invisible label tag
var logintest=e.parameter.logint;
app.getElementById('loginlabel').setTag(logintest);
I want to allow people to change their own password (but I also need to retrieve the login name for other purposes, but let's take this one
When I click on "Modify password" button, I want to get the Tag, but I always get a NULL
var login=app.getElementById('loginlabel').getTag();
I'm free to share my code here or wherever
Maybe it does exist other way to do this, I'm open for advice
In a server handler you can get the tag value using
var tagValue = e.parameter.loginlabel_tag ; // assuming the label has a name = 'loginlabel'
Note that the widget must have a name to be able to retrieve the tag value (see this post among others)

Java Rest Client - Need to add local Variable in URL

Rest client.
Can I add a local variable for value into URL string for a Rest client ?
Example
URL testurl = new URL("http://X.X.X.X:7001/lab2.local.rest1/api/v1/status/database?rxnum=1111");
The above works if I provide literal value for rxnum (i.e. 1111).
But I need rest client to utilize value of a local variable. exam
int rxvalue = 1111;
URL testurl = new URL("http://X.X.X.X:7001/lab2.local.rest1/api/v1/status/database?rxnum=+(rxvalue)+");
this doesn't work, obvious my URL string is incorrect. What is correct syntax to allow URL string to use value of local variable rxvalue?
thanks in advance
URL testurl = new URL("http://X.X.X.X:7001/lab2.local.rest1/api/v1/status/database?rxnum=" +rxvalue);
Simple String concatenation.
You are not building the URL string correctly. It is always a good idea to log url/print to be sure that you are creating the correct url. The problem lies in the way you are trying to concatenate the rxvalue, here is the correction in your code :
String urlString = "http://X.X.X.X:7001/lab2.local.rest1/api/v1/status/database?rxnum=" + rxvalue;
URL testurlWithString = new URL(urlString);
System.out.println(testurlWithString);

Magento change password reset email template

I'm building an e-commerce website using magento 1.6.1.0. I'm using one extension that will force users to login before entering into website. Everything is going fine the problem is only with forgotpassword reset link. That extension is blocking this reset password link also. I didn't got any support from that extension team.
Today morning i worked in email template to change magento default logo. At that time i got one idea that while creating a new account we'll get a details of email, password. why can't we use that email template instead of reset password link template?
I tried copy pasting all contents from account_new.html to account_password_reset_confirmation.html from app/locale/en_US/template/email
After doing these changes i got a email with emailL:xxx#mydomain.com & Password:
I got the mail as empty password field.
Please guide me to change the template of forgot password from account_password_reset_confirmation.html to account_new.html so that i can send the password directly.
may i have your code to debug if you use
$customer = Mage::getModel("customer/customer");
$customer->setWebsiteId(Mage::app()->getWebsite()->getId());
$customer->getPassword();
it wont work.
password will be encrypted in the database. so you cant make use of it. the only way is generating new password and update it in the database and send the new password to the user mail.
sample code to generate custom password
$alphabet = "abcdefghijklmnopqrstuwxyzABCDEFGHIJKLMNOPQRSTUWXYZ0123456789"; //Random password generation
$pass = array(); //remember to declare $pass as an array
$alphaLength = strlen($alphabet) - 1; //put the length -1 in cache
for ($i = 0; $i < 6; $i++) {
$n = rand(0, $alphaLength);
$pass[] = $alphabet[$n];
}
$newpassword =implode($pass);

Get username from SecurityIdentifier

I am using Windows Authentication on a website where users create reports that are stored in a database. When I save a report, I want to know which user filled it out, so I have been storing the SecurityIdentifier of their WindowsIdentity in the database to identify which user filled out the report. Here is the code I use to get the SecurityIdentifier value for the current Windows user:
public static string GetCurrentUserSID()
{
IPrincipal princ = HttpContext.Current.User;
WindowsIdentity winId = princ.Identity as WindowsIdentity;
SecurityIdentifier si = winId.User;
string securityIdentifierValue = winId.User.Value;
return securityIdentifierValue;
}
Questions
Am I doing the right thing by storing the SecurityIdentifier in the database instead of username or some other value? What is the best practice to follow in this sort of situation?
How can I get the user’s username from the SecurityIdentifier value I have stored?
Should contain the username:
HttpContext.Current.User.Identity.Name