last day (14 days later) » 

6:56 AM
1
A: how to get current url from UI Router - State?

WeedozeYou don't need the url because you are using states You should use this method $state.go("serialCreateCase", {sn: 12345}); This will send the user to state serialCreateCase with the data Key : sn Value : 12345 EDIT You code inside the controller should look like this if (toState.name ==...

 
I am not able to understand your answer, can you update from my code? here I don't know the serial number what user will enter
 
Where is your code written ? Inside the controller ? On a button click ?
 
in side a controllers with stateChangeStart, when the user type any number, I would like to send them there
 
@3gwebtrain I updated the answer. When user type inside an input ?
 
no, I am calling from other application like this : 'xyz/sn=1234' - here the number I don't know. the number is dynamic here
 
6:56 AM
I don't understand what you want..Can you edit your question and add clearly step by step your goal ? On which page are you ? What is the user action ? What should happend ?
 
hi there..
 
Yep
So.. Where is the user on start ?
 
i have 2 application in same domain
in first application user will select one of the serial number and click proceed
i will carry that number to other application like this: 'myapp/sr=1234'
 
Thus first user is in the page with url
domainA.com/selection
He will select a serial number and need to be redirected to
domainB.com/sr=12345
Is that right ?
 
so, when i find that, my state with serial number, i should not check the authentication, because they came from one of other application only, so I would like to take them directly
yes, you are correct
 
7:01 AM
Thus why do you need the url if this is a totally different one ?
You can simply use
`window.location = "http://www.yoururl.com";`
window.location = "http://domainB.com/sr=12345";
 
but my app requires the authentication, how to avoid the authentication again
I want to skip the authentication
 
Is there a link between both application ? Or are they completely separated ?
Separated database ? server ? client ,
?*
 
completely seperated, but from same server
 
same database ?
 
yes
both can use the same token
 
7:04 AM
Then when usr is redirected you can call the server just before and add a flag inside the user table
 
in data base are you say?
 
USER A selects serial number 12345
UPDATE USER A inside database. Set flag 'authenticationRequired' to false
REDIRECT USER A to other application
USER A lands on second application
UPDATE USER A in database. Set flag 'AuthenticationRequired' to true
Or keep the information in the server if you can
 
I don't have any control over the data base. all i am doing in front end. let me tell you the steps
1. user login in to app1 and token generated and kepted in cookies or localstorge
 
Then you can send token with the link
window.location = "http://domainB.com/sr=12345&token=qsksq4d135";
 
2. after user select a serial number, i require to open app2 to directly the serial number without asking the authentication
this is what the requirement
But I am asking the credientials if I send like you say. as well I don't know how to set the authentication before I open the URL
 
7:10 AM
If you are sending the token, when user will land on the page he will send the token to the server which will validate it
 
yes. it should
 
Then you can do it like this
Just send the token
 
my app1 - session storage consoles like this: {
"479578a155924d6085cbd77256dfbb8apriority": "1"
}
But I dont' know which is token here at all
my local storage has this value :
{
"stncInfo": "[object Object]",
"userInfoDispatcher": "{\"profile\":{\"contactInfo\":{\"givenname\":\"Mohamed\",\"sn\":\"Arif\",\"accesslevel\":\"4\"},\"locale\":{},\"vps\":{\"accesslevel\":\"4\",\"gutcid\":\"173.37.111.55.1461574795576340\",\"application_networking_services\":\"\",\"cisco_interfaces_and_modules\":\"\",\"service_exchange\":\"\",\"network_management\":\"\",\"optical_networking\":\"\",\"routers\":\"\",\"security_and_vpn\":\"\",\"storage_networking\":\"\",\"switches\":\"\",\"universal_gateways_and_access_servers\":\"\",\"video\":\"\",\"voice_and_ip_communications\":\"\",\"wir
 
Where do you receive your token ?
When user log in you should store token
 
in above informaiton, is not there a token?
 
7:20 AM
I don't know where you store your token
You should know it
Localstorage or coockies
 
yes, both I show here. because I joined in between to the developement
the person resigned who worked before
 
I cant tell you how you stored your token... You may store it with just a letter or a string... I can't find it for you... If you did the front end you should know where it is... If you dont know just go in the code and search
 
at present I am redirecting like this :
$rootScope.goToView("/sn="+toParams.serialNumber);
it works. But I am getting an error as :
angular.js:11706 Error: Could not resolve '/sn=45678' from state '' - I don't know about
what it is? do you have any idea?
 
Why are you talking about that ? You cannot go to a state if the state is located inside another app...
 
now I am talking about app2 - which is falls on me
let me update the client app1 - regarding
which i din't developed, so let them advice me on to bring the token
I have updated my code like this:
if($rootScope.isUserLoggedIn){
if(toState.name === "serialCreateCase"){
$rootScope.goToView("/sn="+toParams.serialNumber);
event.preventDefault();
}
}else if(toState.name!=="login" && toState.name!=="oauth"){
$rootScope.goToView("login");
event.preventDefault();
}
is this ok?
 
7:32 AM
yep
 
so, how to fix that error? what it is?
 

last day (14 days later) »